Vidu - Text-to-Video API reference
The Vidu text-to-video model generates a smooth video from a text prompt .
ImportantThis 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
Note
- After the task is created successfully, use the
task_idreturned 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.
Request parametersRequest headersContent-Type The content type of the request. Must be X-DashScope-Async Asynchronous processing configuration parameter. HTTP requests support asynchronous mode only, and it must be set to ImportantIf this request header is missing, the error "current user api does not support synchronous calls" is returned. Request bodymodel The model name. Valid values:
input The model's input, such as the prompt. parameters Parameters for video generation, such as resolution and duration. | Text-to-video |
Response parametersoutput 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. | Successful responseSave the task_id for querying the task status and result. Error responseTask creation failed. See Error codes. |
Step 2: Query task result
China (Beijing): GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
Note
- 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 headersAuthorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. Path parameterstask_id The ID of the task. | Query task resultReplace |
Response parametersoutput Details of the task output. usage Statistics for the output, counted only for successful tasks. request_id Unique request identifier for tracing and troubleshooting. | Task succeededVideo URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. Task failedIf the task fails, task_status is set to FAILED, and an error code and message are provided. See Error codes for troubleshooting. Task query expiredThe task_id is valid for query for 24 hours. After it expires, the query fails and the following error message is returned. |
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
ImportantEnsure the DashScope Python SDK version isat least2.0.1 before running the following code.
China (Beijing): region="cn-beijing"
Synchronous 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_urlis 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"
}
}
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_async_call_t2v():
# call async api, will return the task information
try:
job = client.videos.jobs.create(model='vidu/viduq3-turbo_text2video',
prompt='一只小猫在月光下奔跑',
size='1024*576',
duration=5,
resolution='540P')
print(job)
print("task_id: %s" % job.task_id)
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")
return
# get the task information include the task status.
try:
snapshot = client.videos.jobs.fetch(job.task_id)
print(snapshot.status) # check the task status
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")
# wait the task complete
try:
done = client.videos.jobs.wait(job)
print(done)
print(done.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_async_call_t2v()
Response example
- Response example for creating a task
{
"request_id": "c86ff7ba-8377-917a-90ed-xxxxxx",
"task_id": "721164c6-8619-4a35-a6d9-xxxxxx",
"status": "PENDING"
}
- Response example for querying the task status
The
video_urlis 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
ImportantEnsure 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
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_urlis 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": ""
}
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();
// 异步调用
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("please wait...");
//获取结果
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
- 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": ""
}
- Response example for querying the task status
The
video_urlis 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=720Pand its corresponding defaultsizevalue (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.