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 .
ImportantThis 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.
NoteThe 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.
Note
- After the task is created, use the
task_idreturned by the API to query the results. The task_id is valid for 24 hours. Do not create the task repeatedly; simply poll for the results.
Request parametersRequest headersContent-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 Asynchronous processing configuration parameter. HTTP requests support asynchronous mode only, and it must be set to ImportantIf this request header is missing, the error "current user api does not support synchronous calls" is returned. Request bodymodel 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. | Generate a video from first and last framesSupported models: pixverse/pixverse-c1-kf2v, pixverse/pixverse-v6-kf2v, and pixverse/pixverse-v5.6-kf2v. Python SDK |
Response parametersoutput 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. | Successful responseSave the task_id, which is used to query the task status and results. Error responseTask creation failed. 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}
Note
- Polling recommendation: Video generation takes several minutes. We recommend using a polling mechanism and setting a reasonable query interval (for example, 15 seconds) to obtain the results.
- Task status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (failed).
- task_id validity: 24 hours. Once it expires, the results can no longer be queried, and the API returns the task status
UNKNOWN. - RPS limits: The default RPS of the query API is 20. For more frequent queries or event notifications, we recommend configuring asynchronous task callbacks.
- More operations: For operations such as batch queries and task cancellation, see Manage asynchronous tasks.
Request parametersRequest headersAuthorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. Path parameterstask_id The ID of the task. | Query the task resultReplace |
Response parametersoutput 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. | Task successfulTask failedIf the task execution fails, task_status is set to FAILED, and an error code and message are provided. See Error codes for troubleshooting. Task query expiredThe task_id is valid for queries within 24 hours. After it expires, queries are no longer possible and the following error message is returned. |
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.