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 .
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 Model: Confirm the region of the model.
- Select URL: Select the Endpoint URL of the corresponding region. HTTP URL is supported.
- Configure API Key: Select a region and obtain and configure an API Key, then configure the API Key in environment variables.
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://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
- After the task is created successfully, use the
task_idreturned by the API to query the result. task_id is valid for 24 hours. Do not create tasks repeatedly; just poll for the result. - For beginner guidance, see Postman.
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)Asynchronous processing configuration parameter. HTTP requests only support asynchronous mode, and it must be set to enable.Request bodymodelstring (Required)Model name. Valid values:
object (Required)Basic input information, including the first frame, last frame image, and prompt.
Properties prompt string (Required)The text prompt. It describes the transition process from the first frame to the last frame.Both Chinese and English are supported. Each Chinese character or letter counts as one character. The maximum length is 5,000 characters. Any excess characters are automatically truncated.Example: A kitten jumps down from the windowsill, lands lightly on the sofa, and then looks around curiously.For more information about how to write prompts, see Vidu Video Generation Prompt Guide.media array (Required)A list of media resources, including the first and last frame images.Each element in the array is a media object that contains type and url fields.
Properties type string (Required)The media type. The static field is:
string (Required)The publicly accessible URL of the image.
object (Required)Video generation parameters, such as video resolution and duration.
Properties resolution string (Required)The resolution of the generated video. Valid values:
integer (Required)The duration of the generated video, in seconds.
boolean (Optional)Supported models: vidu/viduq3-pro_start-end2video, vidu/viduq3-turbo_start-end2video.Whether to generate a video with audio. When enabled, the model automatically generates matching background music or sound effects based on the video content.
boolean (Optional)Whether to add a watermark. The watermark is located in the lower-right corner of the video, with the fixed text "AI-generated content".
integer(Optional)Random number seed. The value range is [0, 2147483647].If not specified, the system automatically generates a random seed. To improve the reproducibility of generated results, it is recommended to use a fixed seed value.Note: Because model generation is probabilistic, even with the same seed, identical results are not guaranteed for each generation. |
|
Response ParametersoutputobjectTask 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.codestringError code. Returned only for failed requests. See Error codes.messagestringDetailed error message. Returned only for failed requests. See Error codes. |
Save the task_id for querying task status and results. |
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 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 parametersRequest headersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.URL 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 |
Response parametersoutputobjectTask 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_urlstringVideo URL. Returned only when task_status is SUCCEEDED.The video is in MP4 format (H.264 encoding). The video link is valid for 24 hours. We recommend that you download it promptly.orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.codestringError code. Returned only for failed requests. See Error codes.messagestringDetailed error message. Returned only for failed requests. See Error codes.objectStatistics for the output information. This parameter is counted only for successful results.
Properties duration integerThe total billable video duration in seconds. Example: 5.output_video_durationintegerThe duration of the output video in seconds. Example: 5.size stringThe resolution of the output video. Example: 828*624.fps integerThe frame rate of the output video. Example: 24.SR stringThe resolution tier of the output video. Example: 540.audio booleanIndicates whether the output video has sound. Example: false.video_count integerThe number of output videos. This is a static field with a value of 1.stringUnique 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.