Skip to main content

Vidu - Image-to-video - First and last frame API reference

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.

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_id returned 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 parameters

Request headers
Content-Type string (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.
If this request header is missing, the error "current user api does not support synchronous calls" is returned.
Request body
model string (Required)Model name. Valid values:
  • vidu/viduq3-pro_start-end2video
  • vidu/viduq3-turbo_start-end2video
  • vidu/viduq2-pro_start-end2video
  • vidu/viduq2-turbo_start-end2video
input 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:
  • image: Image URL.
Material limits:
  • There must be exactly 2 images.
  • The first image in the array represents the first frame, and the second image represents the last frame.
url string (Required)The publicly accessible URL of the image.Image limits:
  • Format: JPG, PNG, WEBP.
  • Aspect ratio: 1:4 to 4:1.
  • File size: No more than 50 MB.
  • Resolution: The resolutions of the first and last frames must be similar. The ratio of their total pixel values (width × height) must be between 0.8 and 1.25.
parameters object (Required)Video generation parameters, such as video resolution and duration.

Properties

resolution string (Required)
resolution directly affects the fee. Confirm the model pricing before calling.
The resolution of the generated video. Valid values:
  • 540P
  • 720P: Default value.
  • 1080P
duration integer (Required)
duration directly affects the fee. Billing is per second; the longer the duration, the higher the fee. Confirm the model pricing before calling.
The duration of the generated video, in seconds.
  • vidu/viduq3-pro_start-end2video, vidu/viduq3-turbo_start-end2video: an integer in [1, 16]. Default value is 5.
  • vidu/viduq2-pro_start-end2video, vidu/viduq2-turbo_start-end2video: an integer in [1, 10]. Default value is 5.
audio 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.
  • false: Default value; outputs a video without audio.
  • true: Outputs a video with audio.
watermark 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".
  • false: Default value; no watermark added.
  • true: Adds a watermark.
seedinteger(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.
  • First and Last Frame to Video
  • Python SDK
curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "vidu/viduq3-turbo_start-end2video",
    "input": {
        "media": [
            {
                "type": "image",
                "url": "https://wanx.alicdn.com/material/20250318/first_frame.png"
            },
            {
                "type": "image",
                "url": "https://wanx.alicdn.com/material/20250318/last_frame.png"
            }
        ],
        "prompt": "一只小猫从窗台向下跳跃,轻盈地落在沙发上,然后好奇地环顾四周。"
    },
    "parameters": {
        "resolution": "540P",
        "duration": 5,
        "watermark": true
    }
}'

Response Parameters

output objectTask output information.

Properties

task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.

Enumeration values

  • PENDING
  • RUNNING
  • SUCCEEDED
  • FAILED
  • CANCELED
  • UNKNOWN: The task does not exist or its status is unknown.
request_idstringUnique 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.
  • Successful response
  • Error response
Save the task_id for querying task status and results.
{
    "output": {
        "task_status": "PENDING",
        "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
    },
    "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}

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 parameters

Request headers
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.
URL path parameters
task_id string (Required)The ID of the task.
  • Query task result
Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours
curl -X GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Response parameters

outputobjectTask output information.

Properties

task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.

Enumeration values

  • PENDING
  • RUNNING
  • SUCCEEDED
  • FAILED
  • CANCELED
  • UNKNOWN: The task does not exist or its status is unknown.
State transitions during polling:
  • PENDING → RUNNING → SUCCEEDED or FAILED.
  • The initial query status is usually PENDING or RUNNING.
  • When the status changes to SUCCEEDED, the response contains the generated video URL.
  • If the status is FAILED, check the error message and retry the task.
submit_time 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.
usage 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.
request_idstringUnique request identifier for tracing and troubleshooting.
  • Task successful
  • Task failed
  • Task query expired
{
    "request_id": "cf7a3a1d-27b0-4d45-8b89-xxxxxx",
    "output": {
        "task_id": "88125b85-b53d-45f1-ba13-xxxxxx",
        "task_status": "SUCCEEDED",
        "submit_time": "2026-03-27 14:39:15.041",
        "scheduled_time": "2026-03-27 14:39:15.081",
        "end_time": "2026-03-27 14:40:03.428",
        "orig_prompt": "一只小猫从窗台向下跳跃,轻盈地落在沙发上,然后好奇地环顾四周。",
        "video_url": "https://prod-ss-vidu.s3.cn-northwest-1.amazonaws.com.cn/xxx.mp4?xxx"
    },
    "usage": {
        "duration": 5,
        "size": "828*624",
        "output_video_duration": 5,
        "fps": 24,
        "video_count": 1,
        "audio": false,
        "SR": "540"
    }
}

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.