Skip to main content

Vidu - Text-to-Video API reference

The Vidu text-to-video model generates a smooth video from a text prompt .

This document applies only to the China (Beijing) region. Use an API key from this region.

Service activation

Go to the Alibaba Cloud Model Studio console, search for Vidu, find the Vidu model card, and click Activate Now. In the dialog box, confirm the activation and authorization.

Prerequisites

To ensure successful calls, make sure the model, endpoint URL, and API key are all in the same region. Cross-region calls will fail.

HTTP calls

Because text-to-video tasks are time-consuming (typically 1–5 minutes), the API uses an asynchronous call. The process consists of two core steps: "Create a task -> Poll for results".

Step 1: Create a task

China (Beijing): 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. The task_id is valid for 24 hours. Do not create the task repeatedly; poll to retrieve the result.
  • For a beginner's guide, see Postman.

Request parameters

Request headers
Content-Type string (Required)The content type of the request. Must be application/json.X-DashScope-Async string (Required)Asynchronous processing configuration parameter. HTTP requests support asynchronous mode only, 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)The model name. Valid values:
  • vidu/viduq3-pro_text2video
  • vidu/viduq3-turbo_text2video
  • vidu/viduq2_text2video
input object (Required)The model's input, such as the prompt.

Properties

prompt string (Required)The text prompt, which describes the desired elements and visual characteristics of the generated video.Both Chinese and English are supported. Each Chinese character or letter is counted as one character. The prompt cannot exceed 5,000 characters; any text beyond this limit is automatically truncated.Example: A kitten running in the moonlight.For more information about how to write prompts, see Vidu Video Generation Prompt Guide.
parameters object (Optional)Parameters for video generation, such as resolution and duration.

Properties

resolution string (Optional)
Resolution directly affects cost. Check Model Pricing before you call the API.
The resolution tier. Valid values:
  • 540P
  • 720P: Default.
  • 1080P
size string (Optional)The resolution of the generated video, in pixels, in the format width*height.The default value depends on resolution:
  • When the resolution is 540P, the size defaults to 1024*576.
  • When resolution=720P, size defaults to 1280*720.
  • When resolution=1080P, size defaults to 1920*1080.

Resolution tier

Aspect ratio

Size (width*height)

540P

16:9

1024*576

9:16

576*1024

1:1

1024*1024

4:3

1024*768

3:4

768*1024

720P

16:9

1280*720

9:16

720*1280

1:1

1280*1280

4:3

1280*960

3:4

960*1280

1080P

16:9

1920*1080

9:16

1080*1920

1:1

1808*1808

4:3

1920*1440

3:4

1440*1920

duration integer (Optional)
Duration directly affects cost, as billing is per second. Check Model Pricing before you call the API.
The duration of the generated video, in seconds.
  • vidu/viduq3-pro_text2video and vidu/viduq3-turbo_text2video: an integer in the range [1, 16]; the default value is 5.
  • vidu/viduq2_text2video: an integer in the range [1, 10]; the default value is 5.
audio boolean (Optional)Supported models: vidu/viduq3-pro_text2video, vidu/viduq3-turbo_text2video.Specifies whether to generate a video with audio. If set to true, the model automatically generates matching background music or sound effects based on the video content.
  • false: Default. Outputs a video without audio.
  • true: Outputs a video with audio.
watermark boolean (Optional)Specifies whether to add a watermark. The watermark is placed in the bottom-right corner of the video with the fixed text "Generated by AI".
  • false: Default. No watermark is added.
  • true: Adds a watermark.
seed integer (Optional)The random number seed must be an integer in the range [0, 2147483647].If not specified, a random seed is generated. A fixed seed improves reproducibility.Because model generation is probabilistic, the same seed does not guarantee identical results.
  • Text-to-video
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_text2video",
    "input": {
        "prompt": "一只小猫在月光下奔跑"
    },
    "parameters": {
        "size": "1024*576",
        "resolution": "540P",
        "duration": 5,
        "watermark": true
    }
}'

Response parameters

output objectDetails of the task output.

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 the task status and result.
{
    "output": {
        "task_status": "PENDING",
        "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
    },
    "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}

Step 2: Query task result

China (Beijing): GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
  • Polling recommendation: Video generation can take several minutes. We recommend using a polling mechanism with a reasonable query interval (e.g., 15 seconds) to retrieve the result.
  • Task status flow: PENDING (queued) → RUNNING (in progress) → SUCCEEDED (succeeded) / FAILED (failed).
  • task_id validity: 24 hours. After this period, you can no longer query the result, and the API returns a task status of UNKNOWN.
  • RPS limit: The query endpoint has a default RPS (Requests Per Second) limit of 20. For higher-frequency queries or event notifications, we recommend that you configure an asynchronous task callback.
  • More operations: For operations such as bulk queries or canceling tasks, see Manage Asynchronous Tasks.

Request parameters

Request headers
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.
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

outputobjectDetails of the task output.

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_urlstringThe video URL. Returned only when task_status is SUCCEEDED.The video is in MP4 format (H.264 encoded). The video URL is valid for 24 hours. Please 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, counted only for successful tasks.

Properties

duration integerTotal 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: 960*528.fps integerThe frame rate of the output video. Example: 24.SR stringThe resolution tier of the generated video. Example: 540.audio booleanIndicates whether the generated video includes audio. Example: false.video_count integerThe number of generated videos. This value is always 1.
request_idstringUnique request identifier for tracing and troubleshooting.
  • Task succeeded
  • Task failed
  • Task query expired
Video URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly.
{
    "request_id": "eda50dad-a6d3-4e62-a70b-26bbb797ae81",
    "output": {
        "task_id": "d9254244-1f9b-4b4c-be82-d9560ba25708",
        "task_status": "SUCCEEDED",
        "submit_time": "2026-03-27 13:32:13.962",
        "scheduled_time": "2026-03-27 13:32:14.008",
        "end_time": "2026-03-27 13:32:43.375",
        "orig_prompt": "一只小猫在月光下奔跑",
        "video_url": "https://prod-ss-vidu.s3.cn-northwest-1.amazonaws.com.cn/xxx.mp4?xxx"
    },
    "usage": {
        "duration": 5,
        "size": "960*528",
        "output_video_duration": 5,
        "fps": 24,
        "video_count": 1,
        "audio": false,
        "SR": "540"
    }
}

SDK calls

The parameter names in the SDK are largely consistent with the HTTP interface, and the parameter structure is adapted to the features of each programming language. Because text-to-video tasks are time-consuming (typically 1-5 minutes), the SDK encapsulates the asynchronous HTTP call process and supports both synchronous and asynchronous calls.
The actual processing time depends on the number of tasks in the queue and the service's operational status. Be patient when retrieving the results.

Python

Ensure the DashScope Python SDK version isat least2.0.1 before running the following code.
China (Beijing): region="cn-beijing"
  • Synchronous call
  • Asynchronous call
Request example
import os
import dashscope
from dashscope import DashScopeError

# 以下为华北2(北京)地域的配置。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的region取值不同。
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
client = dashscope.Client(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

def sample_sync_call_t2v():
    # call sync api, will return the result
    print('please wait...')
    # generate 为一步式调用(提交任务并等待完成),返回已完成的 Job
    try:
        job = client.videos.generate(model='vidu/viduq3-turbo_text2video',
                                     prompt='一只小猫在月光下奔跑',
                                     size='1024*576',
                                     duration=5,
                                     resolution='540P',
                                     watermark=True)
        print(job)
        print(job.video_url)
    except DashScopeError as e:
        print(f"HTTP返回码:{e.status_code}")
        print(f"错误码:{e.code}")
        print(f"错误信息:{e.message}")
        print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")

if __name__ == '__main__':
    sample_sync_call_t2v()
Response example
The video_url is valid for 24 hours. Download the video promptly.
{
    "request_id": "15bd86e5-28b1-40ad-a427-xxxxxx",
    "task_id": "a876c6ee-1c63-4d17-b6c0-xxxxxx",
    "status": "SUCCEEDED",
    "results": [
        {
            "video_url": "https://prod-ss-vidu.s3.cn-northwest-1.amazonaws.com.cn/xxx.mp4?xxx"
        }
    ],
    "task_metrics": {
        "TOTAL": 1,
        "SUCCEEDED": 1,
        "FAILED": 0
    },
    "usage": {
        "video_count": 1,
        "video_duration": 0,
        "video_ratio": "",
        "duration": 5,
        "size": "960*528",
        "output_video_duration": 5,
        "fps": 24,
        "audio": false,
        "SR": "540"
    }
}

Java

Ensure the DashScope Java SDK version isat least2.22.6 before running the following code.
China (Beijing): Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
  • Synchronous call
  • Asynchronous call
Request example
// Copyright (c) Alibaba, Inc. and its affiliates.

import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;

public class Text2Video {

    static {
        // 以下为北京地域URL,调用时请将 {WorkspaceId} 替换为真实的业务空间ID
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
    }

    // 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
    public static String apiKey = System.getenv("DASHSCOPE_API_KEY");

    /**
     * Create a video compositing task and wait for the task to complete.
     */
    public static void text2Video() throws ApiException, NoApiKeyException, InputRequiredException {
        VideoSynthesis vs = new VideoSynthesis();
        VideoSynthesisParam param =
                VideoSynthesisParam.builder()
                        .apiKey(apiKey)
                        .model("vidu/viduq3-turbo_text2video")
                        .prompt("一只小猫在月光下奔跑")
                        .size("1024*576")
                        .resolution("540P")
                        .duration(5)
                        .watermark(true)
                        .build();
        System.out.println("please wait...");
        VideoSynthesisResult result = vs.call(param);
        System.out.println(JsonUtils.toJson(result));
    }

    public static void main(String[] args) {
        try {
            text2Video();
        } catch (ApiException | NoApiKeyException | InputRequiredException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
}
Response example
The video_url is valid for 24 hours. Download the video promptly.
{
    "request_id": "bebc5f6b-a081-4b02-ad29-xxxxxx",
    "output": {
        "task_id": "2b0e287f-ebdc-49af-82aa-xxxxxx",
        "task_status": "SUCCEEDED",
        "video_url": "https://prod-ss-vidu.s3.cn-northwest-1.amazonaws.com.cn/infer_92/xxx.mp4?xxx",
        "orig_prompt": "一只小猫在月光下奔跑",
        "submit_time": "2026-03-30 10:19:00.827",
        "scheduled_time": "2026-03-30 10:19:00.879",
        "end_time": "2026-03-30 10:19:28.172"
    },
    "usage": {
        "video_count": 1,
        "duration": 5.0,
        "size": "960*528",
        "input_video_duration": 0.0,
        "output_video_duration": 5.0,
        "SR": "540"
    },
    "status_code": 200,
    "code": "",
    "message": ""
}

Error codes

If a model call fails, see error message for troubleshooting.

FAQ

Q: Do size and resolution have to be passed in together?

A: No. Both are optional parameters, but passing both is recommended to precisely control the aspect ratio of the generated video. For details, see size values. If you do not pass both parameters, the system handles the request in one of the following two ways:
  • Pass in size only: The size parameter is ignored, and the system forcibly processes the request with the default resolution=720P and its corresponding default size value (1280*720).
    For example, the API response is size="1280*720", SR=720.
  • Pass in resolution only: The output uses the specified resolution tier and its corresponding 16:9 aspect ratio.
    Example: When resolution=540P, the API response is size="960540", SR=540; when resolution=1080P, the API response is size="19201080", SR=1080.