The Vidu text-to-video model generates a smooth video from a text prompt .
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.
- Select a model: Confirm the model's region.
- Select a URL: Select the endpoint URL that corresponds to your region. You can use an HTTP URL or a DashScope SDK URL.
- Configure the API key: Select a region, get an API key, and then set the API key as an environment variable.
- Install the SDK: To make calls using the SDK, install the DashScope SDK.
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, 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 parametersRequest headersContent-Typestring (Required)The content type of the request. Must be application/json.X-DashScope-Async string (Required)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be enable.Request bodymodelstring (Required)The model name. Valid values:
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.object (Optional)Parameters for video generation, such as resolution and duration.
Properties resolution string (Optional)The resolution tier. Valid values:
string (Optional)The resolution of the generated video, in pixels, in the format width*height.The default value depends on resolution:
integer (Optional)The duration of the generated video, in seconds.
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.
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".
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. |
|
Response parametersoutputobjectDetails 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
stringUnique request identifier for tracing and troubleshooting.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. |
Save the task_id to query the task status and result. |
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 parametersRequest headersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.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 parametersoutputobjectInformation about the task output.
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_urlstringThe URL of the generated video. This is returned only when the 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.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes.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.stringUnique request identifier for tracing and troubleshooting. |
Video URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. |
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
China (Beijing): dashscope.base_http_api_url = 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1'
- Synchronous call
- Asynchronous call
Request example
Response example
The video_url is valid for 24 hours. Download the video promptly.
Java
China (Beijing): Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
- Synchronous call
- Asynchronous call
Request example
Response example
The video_url is valid for 24 hours. Download the video promptly.
Error codes
If a model call fails, see error message for troubleshooting.
FAQ
Q: Must size and resolution be passed 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 only
size: Thesizeparameter is ignored, and the system defaults toresolution=720Pand uses the correspondingsizeof1280*720.Example: The API response is size="1280*720", SR=720.
-
Pass only
resolution: The system generates a video at the specified resolution tier with a 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.