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.
-
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 parameters |
Text-to-video
|
Request headers |
|
|
Content-Type The content type of the request. Must be |
|
|
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. Valid values:
|
|
|
input The model's input, such as the prompt. |
|
|
parameters Parameters for video generation, such as resolution and duration. |
Response parameters |
Successful responseSave the
Error responseTask creation failed. See Error codes.
|
|
output Details of the task output. |
|
|
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 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 |
Query task resultReplace |
Request headers |
|
|
Authorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. |
|
Path parameters |
|
|
task_id The ID of the task. |
Response parameters |
Task succeededVideo URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. Task failedWhen a task fails,
Task query expiredThe
|
|
output Information about the task output. |
|
|
usage Statistics for the output, counted only for successful tasks. |
|
|
request_id Unique request identifier for tracing and troubleshooting. |
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 is at least 1.25.8 before running the following code.
China (Beijing): dashscope.base_http_api_url = 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1'
Synchronous call
Request example
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# The following is the URL for the China (Beijing) region
dashscope.base_http_api_url = 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1'
# If you have not configured an environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx"
api_key = os.getenv("DASHSCOPE_API_KEY")
def sample_sync_call_t2v():
# Make a synchronous call, which waits for and returns the result.
print('please wait...')
rsp = VideoSynthesis.call(api_key=api_key,
model='vidu/viduq3-turbo_text2video',
prompt='A kitten running under moonlight',
size='1024*576',
duration=5,
resolution='540P',
watermark=True)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.video_url)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
sample_sync_call_t2v()
Response example
The video_url is valid for 24 hours. Download the video promptly.{
"status_code": 200,
"request_id": "15bd86e5-28b1-40ad-a427-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "a876c6ee-1c63-4d17-b6c0-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://prod-ss-vidu.s3.cn-northwest-1.amazonaws.com.cn/xxx.mp4?xxx",
"submit_time": "2026-03-27 13:35:49.508",
"scheduled_time": "2026-03-27 13:35:49.540",
"end_time": "2026-03-27 13:36:45.848",
"orig_prompt": "A kitten running under moonlight"
},
"usage": {
"video_count": 1,
"video_duration": 0,
"video_ratio": "",
"duration": 5,
"size": "960*528",
"output_video_duration": 5,
"fps": 24,
"audio": false,
"SR": "540"
}
}
Asynchronous call
Request example
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# The following is the URL for the China (Beijing) region
dashscope.base_http_api_url = 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1'
# If you have not configured an environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx"
api_key = os.getenv("DASHSCOPE_API_KEY")
def sample_async_call_t2v():
# Make an asynchronous call, which returns task information immediately.
rsp = VideoSynthesis.async_call(api_key=api_key,
model='vidu/viduq3-turbo_text2video',
prompt='A kitten running under moonlight',
size='1024*576',
duration=5,
resolution='540P')
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print("task_id: %s" % rsp.output.task_id)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
# Get the task information, including the task status.
status = VideoSynthesis.fetch(task=rsp, api_key=api_key)
if status.status_code == HTTPStatus.OK:
print(status.output.task_status) # check the task status
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(status.status_code, status.code, status.message))
# Wait for the task to complete.
rsp = VideoSynthesis.wait(task=rsp, api_key=api_key)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.video_url)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
sample_async_call_t2v()
Response example
1. Response example for creating a task
{
"status_code": 200,
"request_id": "c86ff7ba-8377-917a-90ed-xxxxxx",
"code": "",
"message": "",
"output": {
"task_id": "721164c6-8619-4a35-a6d9-xxxxxx",
"task_status": "PENDING",
"video_url": ""
},
"usage": null
}
2. Response example for querying the task status
The video_url is valid for 24 hours. Download the video promptly.{
"status_code": 200,
"request_id": "15bd86e5-28b1-40ad-a427-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "a876c6ee-1c63-4d17-b6c0-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://prod-ss-vidu.s3.cn-northwest-1.amazonaws.com.cn/xxx.mp4?xxx",
"submit_time": "2026-03-27 13:35:49.508",
"scheduled_time": "2026-03-27 13:35:49.540",
"end_time": "2026-03-27 13:36:45.848",
"orig_prompt": "A kitten running under moonlight"
},
"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 is at least 2.22.6 before running the following code.
China (Beijing): Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
Synchronous 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 {
// The following is the URL for the China (Beijing) region
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
}
// If you have not configured an environment variable, replace the following line with your Model Studio API key: apiKey="sk-xxx"
public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
/**
* Create a video synthesis task and wait for it 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("A kitten running under moonlight")
.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": "A kitten running under moonlight",
"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": ""
}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 {
// The following is the URL for the China (Beijing) region
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
}
// If you have not configured an environment variable, replace the following line with your Model Studio API key: apiKey="sk-xxx"
public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
/**
* Creates a video synthesis task asynchronously and then waits for its completion.
*/
public static void text2Video() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("vidu/viduq3-turbo_text2video")
.prompt("A kitten running under moonlight")
.size("1024*576")
.resolution("540P")
.duration(5)
.watermark(true)
.build();
// Asynchronous call
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("please wait...");
// Fetch the result
VideoSynthesisResult result = vs.wait(task, apiKey);
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
1. Response example for creating a task
{
"request_id": "9b583f1b-2423-4fac-bb3f-xxxxxx",
"output": {
"task_id": "3944b819-1bbb-4da0-a230-xxxxxx",
"task_status": "PENDING"
},
"status_code": 200,
"code": "",
"message": ""
}
2. Response example for querying the task status
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": "A kitten running under moonlight",
"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: 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="960*540", SR=540; when resolution=1080P, the API response is size="1920*1080", SR=1080.