PixVerse: Image-to-video from first and last frames API reference
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.
This document applies only to the China (Beijing) region. Use an API key from this region.
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 parameters |
Generate a video from first and last framesSupported models: pixverse/pixverse-c1-kf2v, pixverse/pixverse-v6-kf2v, and pixverse/pixverse-v5.6-kf2v.
|
Request headers |
|
|
Content-Type The content type of the request. Must be |
|
|
Authorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. |
|
|
X-DashScope-Async Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be Important
If this request header is missing, the error "current user api does not support synchronous calls" is returned. |
|
Request body |
|
|
model The model name. Valid values:
|
|
|
input The basic input information, which includes the first frame image, last frame image, and prompt. |
|
|
parameters The video generation parameters, such as the video resolution, duration, and whether to generate audio. |
Response parameters |
Successful responseSave the
Error responseTask creation failed. See Error codes.
|
|
output The task output information. |
|
|
request_id Unique request identifier for tracing and troubleshooting. |
|
|
code Error code. Returned only for failed requests. See Error codes. |
|
|
message Detailed error message. Returned only for failed requests. See Error codes. |
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 parameters |
Query the task resultReplace |
Request headers |
|
|
Authorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. |
|
Path parameters |
|
|
task_id The ID of the task. |
Response parameters |
Task successful
Task failedWhen a task fails,
Task query expiredThe
|
|
output The task output information. |
|
|
usage The statistics of the output information. Only successful results are counted. |
|
|
request_id Unique 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.