The PixVerse model for first and last frames generates a smooth video transition based on a first frame image, a last frame image , and a text prompt .
Activate the service
- Go to the Alibaba Cloud Model Studio console, search for PixVerse, find the PixVerse model card, and click Activate Now.
- In the pop-up window, confirm the activation and authorization.
Scope
To ensure successful invocations, make sure that the model, Endpoint URL, and API key all belong to the same region. Invocations across different regions will fail.
- Select a model: Confirm the region to which the model belongs.
- Select a URL: Select the corresponding regional Endpoint URL. Both HTTP URLs and DashScope SDK URLs are supported.
- Configure an API key: Select a region and obtain an API key. Then, configure the API key as an environment variable.
The sample code in this topic applies to the China (Beijing) region.
HTTP invocation
Generating a video from the first and last frames is a time-consuming task that usually takes 1 to 5 minutes. Therefore, the API uses asynchronous invocation. The process involves two core steps: Create a task -> Poll for the result, as described below:
Step 1: Create a task and get the task ID
Beijing region: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Replace {WorkspaceId} with your actual workspace ID.
- After the task is created, use the returned
task_idto query the result. Thetask_idis valid for 24 hours. Do not create duplicate tasks. Instead, use polling to retrieve the result. - For guidance for beginners, see Call APIs with Postman or cURL.
Request parametersRequest headersContent-Typestring (Required)The content type of the request. Must be application/json.Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.X-DashScope-Async string (Required)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be enable.Request bodymodelstring (Required)The model name.Valid values:
Model selection
object (Required)The basic input information, which includes the first frame image, last frame image, and prompt.
Properties prompt string (Required)The text prompt. It describes the transition from the first frame to the last frame.Both Chinese and English are supported. Each Chinese character or letter is counted as one character. The character encoding is UTF-8. Any excess characters are automatically truncated.
array (Required)The list of media resources, which includes the first and last frame images.Each element in the array is a media object that contains the type and url fields.
Properties type string (Required)The media type.
string (Required)The publicly accessible URL of the image.
object (Required)The video generation parameters, such as the video resolution, duration, and whether to generate audio.
Properties resolution string (Required)The resolution of the generated video.Valid values: 360P, 540P, 720P, or 1080P.duration integer (Required)The duration of the generated video in seconds.
boolean (Optional)Specifies whether to generate a video with sound. If this parameter is enabled, the model automatically generates matching background music or sound effects based on the video content.
boolean (Optional)Specifies whether to add a watermark. The watermark is located in the lower-right corner of the video and displays the fixed text "AI Generated".
integer(Optional)The random number seed. The value must be in the range [0, 2147483647].If this parameter is not specified, the system automatically generates a random seed. To improve the reproducibility of the generation results, you can set a fixed seed value.Note that because model generation is probabilistic, using the same seed does not guarantee that the results are identical every time. |
Supported models: pixverse/pixverse-c1-kf2v, pixverse/pixverse-v6-kf2v, and pixverse/pixverse-v5.6-kf2v. |
Response parametersoutputobjectThe task output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringUnique request identifier for tracing and troubleshooting.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. |
Save the task_id to query the task status and result. |
Step 2: Query the result by task ID
Beijing region: GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
- Polling recommendation: Video generation takes several minutes. We recommend that you use a polling mechanism with a reasonable query interval, such as 15 seconds, to retrieve the result.
- Task status flow: PENDING -> RUNNING -> SUCCEEDED / FAILED.
- task_id validity: 24 hours. After this period, you cannot query the result. The API returns the task status as
UNKNOWN. - RPS limit: The query API has a default limit of 20 records per second (RPS). For higher-frequency queries or event notifications, you can configure an asynchronous task callback.
- More operations: For information about operations such as batch queries and canceling tasks, see Manage asynchronous tasks.
Request parametersRequest headersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.Path parameterstask_idstring (Required)The ID of the task. |
Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours, Replace {WorkspaceId} with your actual workspace ID. |
Response parametersoutputobjectThe task output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. format is YYYY-MM-DD HH:mm:ss.SSS.video_urlstringThe video URL. This parameter is returned only when the task_status is SUCCEEDED.The video format is MP4 with H.264 encoding. The video link does not expire. However, we recommend that you do not use it for long-term storage. Download the video promptly.orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes.objectThe statistics of the output information. Only successful results are counted.
Properties duration integerThe total duration of the generated video, which is used for billing.size stringThe resolution of the generated video.fps integerThe frame rate of the generated video.SR stringThe resolution tier of the generated video.audio booleanIndicates whether the generated video contains sound.video_count integerThe number of generated videos. The value is fixed at 1.stringUnique request identifier for tracing and troubleshooting. |
|
Error codes
If the model call fails and returns an error message, see Error codes for resolution.
FAQ
Q: Does the order of the first and last frames in the media array matter?
A: The media array must contain two objects, with their type fields set to first_frame (first frame) and last_frame (last frame), respectively. The order does not affect the result because the system automatically detects them based on the type field.
Q: Do the first and last frame images need to have the same resolution?
A: No, they do not. The first and last frames can have different resolutions. The system handles this automatically.
The aspect ratio of the output video is approximately the same as that of the first frame. The resolution is automatically adjusted to a similar total pixel count based on the selected resolution setting, such as 720P.