The Vidu first and last frame video generation model creates a smoothly transitioning video 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 Vidu, find the Vidu model card, and click Activate Now. In the pop-up window, confirm the activation and authorization.
Scope
To ensure successful calls, make sure that the model, Endpoint URL, and API key all belong to the same region. Cross-region calls will fail.
-
Select a model: Confirm the region where the model is located.
-
Select a URL: Select the corresponding regional Endpoint URL. HTTP URLs are supported.
-
Configure an API key: Select a region and obtain an API key. Then, configure the API key as an environment variable (to be unpublished and merged into API key configuration).
HTTP calls
Because first and last frame video generation tasks take a long time (typically 1 to 5 minutes), the API uses asynchronous invocation. The entire process involves two core steps: Create a task -> Poll for the result. The procedure is as follows:
Step 1: Create a task and get the task ID
Beijing region: POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
-
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 |
First and last frame video generation
|
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. For more information about available models, see the Model List. Static field: vidu/viduq3-turbo_start-end2video. |
|
|
input Basic input information, including the first frame, last frame image, and prompt. |
|
|
parameters Video generation parameters, such as video resolution and duration. |
Response parameters |
Successful responseSave the
Error responseTask creation failed. See Error codes.
|
|
output 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://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
-
Polling recommendation: Video generation takes several minutes. We recommend that you use a polling mechanism and set a reasonable query interval, such as 15 seconds, to obtain the result.
-
Task status flow: PENDING (In queue) -> RUNNING (Processing) -> SUCCEEDED (Successful) / FAILED (Failed).
-
task_id validity: 24 hours. After this period, you cannot query the result, and the API returns the task status as
UNKNOWN. -
RPS limit: The default records per second (RPS) for the query API is 20. For higher-frequency queries or event notifications, you can configure an asynchronous task callback.
-
More operations: For operations such as batch queries and task cancellation, see Manage asynchronous tasks.
Request parameters |
Query task resultReplace |
Request headers |
|
|
Authorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. |
|
URL path parameters |
|
|
task_id The ID of the task. |
Response parameters |
Task successful
Task failedWhen a task fails,
Task query expiredThe
|
|
output Task output information. |
|
|
usage Statistics for the output information. This parameter is counted only for successful results. |
|
|
request_id Unique request identifier for tracing and troubleshooting. |
Error codes
If a model call fails and returns an error message, see Error messages to resolve the issue.
FAQ
Q: Is there a required order for the first and last frames in the media array?
A: Yes, there is. The media array must contain two type=image objects. The first element represents the first frame, and the second element represents the last frame.
Q: Do the first and last frame images need to have the same resolution?
A: No, they do not. However, we recommend that the resolutions are similar. The ratio of the total pixel count (width × height) between the first and last frames must be between 0.8 and 1.25. A large difference in resolution degrades the generation quality.