Vidu - Image-to-video from an initial frame API reference
The Vidu image-to-video model generates a smooth video from an input 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 Vidu, find the Vidu model card, and click Activate Now. In the dialog box that appears, confirm the activation and authorization.
Scope
The model, Endpoint URL, and API Key must belong to the same region. Cross-region calls will fail.
- Select a model: Confirm the region where the model is available.
- Select a URL: Select the corresponding regional Endpoint URL. HTTP URLs are supported.
- Configure an API Key: Select a region, get an API Key, and then set the API Key as an environment variable.
HTTP calls
Image-to-video generation is a long-running task that typically takes 1 to 5 minutes, so the API uses an asynchronous model. The workflow consists of two core steps: create a task, then poll for the result.
Step 1: Create a task
China (Beijing) region: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Note
- After the task is successfully created, use the
task_idreturned by the interface to query the result. The task_id is valid for 24 hours. Do not create duplicate tasks; use polling to obtain the results.
Request parametersHeadersContent-Type The content type of the request. Must be Content-Type The content type of the request. Must be 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 name of the model. Valid values are:
input The basic input, including the text prompt and media assets. parameters Parameters for video processing, such as resolution and duration. | Image-to-videoPython SDK |
Response parametersoutput 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
China (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 with a reasonable query interval (such as 15 seconds) to obtain the results.
- Task status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- task_id validity: 24 hours. After it expires, the result can no longer be queried, and the interface will return a task status of
UNKNOWN. - RPS limit: The default RPS of the query interface is 20. For higher-frequency queries or event notifications, we recommend configuring asynchronous task callbacks.
- More operations: For batch queries, task cancellation, and other operations, see Managing asynchronous tasks.
Request parametersHeadersAuthorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. Path parameterstask_id The ID of the task. | Query task resultReplace |
Response parametersoutput Task output information. usage Output usage statistics, counted only for successful tasks. request_id Unique request identifier for tracing and troubleshooting. | Task succeededTask failedIf the task fails, task_status will be set to FAILED, and an error code and message will be provided. See Error codes for troubleshooting. Task query expiredThe task_id can be used for queries within 24 hours. After that, queries are no longer available, and the following error message is returned. |
Error codes
If a model call fails, see Error Messages to troubleshoot the error.