The Wan text-to-video model generates smooth videos from text prompts.
References: User guide
Availability
To ensure successful calls, the model, Endpoint URL, and API Key must all belong to the same region. Cross-region calls will fail.
-
Select a model: Confirm the region of the model.
-
Select a URL: Choose the corresponding regional Endpoint URL. HTTP URLs and DashScope SDK URLs are supported.
-
Configure an API key: Select a region, get an API key, and then configure the API key as an environment variable (to be deprecated and merged into API key configuration).
-
Install the SDK: To make calls using the SDK, you must install the DashScope SDK.
The sample code in this topic applies to the Beijing region.
Alibaba Cloud Model Studio has released workspace-specific domains for the China (Beijing) and Singapore regions. The new dedicated domains deliver superior performance and higher stability for inference requests. We recommend migrating to the new domains:
China (Beijing): from
https://dashscope.aliyuncs.comtohttps://{WorkspaceId}.cn-beijing.maas.aliyuncs.comSingapore: from
https://dashscope-intl.aliyuncs.comtohttps://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
{WorkspaceId} is your workspace ID, which can be found on the Workspace Details page in the Alibaba Cloud Model Studio console. The existing domain remains fully functional.
HTTP
This API uses the legacy protocol and supports wan2.6 and earlier models (wan2.5/wan2.2/wanx2.1).
Because text-to-video 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 process is as follows:
Step 1: Create a task and get the task ID
Beijing
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Replace {WorkspaceId} with your actual workspace ID.
Singapore
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Replace {WorkspaceId} with your actual workspace ID.
Virginia
POST https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Frankfurt
POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Replace {WorkspaceId} with your actual workspace ID.
-
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 |
Multi-shot narrative
Provide an audio fileSupported models: wan2.6/wan2.5 series models. You can provide the URL of a custom audio file using the
Automatic dubbingSupported models: wan2.6/wan2.5 series models. If you do not provide
Generate a silent videoOnly the wan2.2 and wanx2.1 series models support silent video generation. These models generate silent videos by default, and no additional configuration is required. The wan2.6 and wan2.5 series models generate videos with audio by default.
Use a negative promptSupported models: All models. Use the negative_prompt parameter to exclude the "flower" element and prevent it from appearing in the video.
|
Request headers |
|
|
Content-Type The content type of the request. Must be |
|
|
Authorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. |
|
|
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 name of the model to use. For a list of available models, see the model list. Example: wan2.6-t2v. |
|
|
input Contains basic input information, such as the prompt. |
|
|
parameters Video processing parameters, such as setting the video resolution, enabling prompt rewriting, and adding a watermark. |
Response parameters |
Successful responseSave the
Error responseTask creation failed. See Error codes.
|
|
output Contains the task output information. |
|
|
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 the result by task ID
Beijing
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
Replace {WorkspaceId} with your actual workspace ID.
Singapore
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Replace {WorkspaceId} with your actual workspace ID.
Virginia
GET https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Frankfurt
GET https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Replace {WorkspaceId} with your actual workspace ID.
-
Polling recommendation: Video generation takes several minutes. Use a polling mechanism with a reasonable interval, such as 15 seconds.
-
Task state transition: PENDING → RUNNING → SUCCEEDED or FAILED.
-
Result link: After a task succeeds, a video URL valid for 24 hours is returned. Download and save the video to permanent storage, such as OSS.
-
task_idvalidity: 24 hours. After this period, queries return the task status asUNKNOWN. -
RPS limit: The default RPS for the query API is 20. For higher-frequency queries or event notifications, we recommend that you configure an asynchronous task callback.
-
More operations: For batch queries, task cancellation, and other operations, 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. |
|
URL path parameters |
|
|
task_id The ID of the task. |
Response parameters |
Task successfulVideo URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly.
Task failedWhen a task fails,
Task query expiredThe
|
|
output Contains the task output information. |
|
|
usage Contains statistics about the output. This information is provided only for successful tasks. |
|
|
request_id Unique request identifier for tracing and troubleshooting. |
DashScope SDK
The parameter names in the SDK are mostly consistent with the HTTP API, and the parameter structure is encapsulated to align with the features of the programming language.
Because text-to-video tasks can take a long time to complete (typically 1 to 5 minutes), the SDK encapsulates the HTTP asynchronous call process and supports both synchronous and asynchronous invocation methods.
The actual processing time depends on the number of tasks in the queue and the service status. Wait for the result.
Python
Make sure your DashScope Python SDK version is at least 1.25.16 before running the following code.
If you use an older version, you may encounter errors such as "url error, please check url!". To update the SDK, see Install the SDK.
Set dashscope.base_http_api_url based on the region where the model is located:
Beijing
dashscope.base_http_api_url = 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1'
Replace {WorkspaceId} with your actual workspace ID.
Singapore
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
Replace {WorkspaceId} with your actual workspace ID.
Virginia
dashscope.base_http_api_url = 'https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1'
Frankfurt
dashscope.base_http_api_url = 'https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1'
Replace {WorkspaceId} with your actual workspace ID.
Synchronous invocation
Request example
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# Beijing region URL. Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. For more information, see https://help.aliyun.com/en/model-studio/text-to-video-api-reference.
dashscope.base_http_api_url = 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1'
# If no environment variable is configured, replace with your Model Studio API key: api_key="sk-xxx".
# API keys vary by region. For more information, see https://help.aliyun.com/en/model-studio/get-api-key.
api_key = os.getenv("DASHSCOPE_API_KEY")
def sample_sync_call_t2v():
# Call the sync API and return the result.
print('Please wait...')
rsp = VideoSynthesis.call(api_key=api_key,
model='wan2.6-t2v',
prompt='An epic and cute scene. A small, adorable cartoon kitten general, wearing exquisitely detailed golden armor and a slightly oversized helmet, stands bravely on a cliff. He rides a small but heroic warhorse and says: "The long clouds of Qinghai darken the snowy mountains, a lone city gazes at Yumen Pass from afar. Through a hundred battles in the yellow sand, the golden armor is worn, but we will not return until we have broken Loulan". Below the cliff, a vast and endless army of mice with makeshift weapons is charging forward. This is a dramatic, large-scale battle scene inspired by ancient Chinese war epics. In the distance, dark clouds gather in the sky over the snowy mountains. The overall atmosphere is a comical and epic fusion of "cute" and "domineering".',
audio_url='https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250923/hbiayh/%E4%BB%8E%E5%86%9B%E8%A1%8C.mp3',
size='1280*720',
duration=10,
negative_prompt="",
prompt_extend=True,
watermark=False,
seed=12345)
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 promptly.
{
"status_code": 200,
"request_id": "167f3beb-3dd0-47fe-a83c-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "5b65411f-d946-4e29-859e-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-bj.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
"submit_time": "2025-10-23 11:47:23.879",
"scheduled_time": "2025-10-23 11:47:34.351",
"end_time": "2025-10-23 11:52:35.323",
"orig_prompt": "An epic and cute scene featuring a small, adorable cartoon kitten general. Wearing exquisitely detailed golden armor and a slightly oversized helmet, he stands bravely on a cliff. He rides a small but heroic warhorse and recites: 'The long clouds of Qinghai darken the snowy mountains, a lone city gazes at Yumen Pass from afar. Through a hundred battles in the yellow sand, the golden armor is worn, but we will not return until we have broken Loulan.' Below the cliff, a vast army of mice with makeshift weapons charges forward. The scene is a dramatic, large-scale battle inspired by ancient Chinese war epics. In the distance, dark clouds gather over snowy mountains. The overall atmosphere is a comical and epic fusion of 'cute' and 'domineering'."
},
"usage": {
"video_count": 1,
"duration": 10,
"size": "1280*720",
"input_video_duration": 0,
"output_video_duration": 10,
"SR": 720
}
}Asynchronous invocation
Request example
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# Beijing region URL. Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. For more information, see https://help.aliyun.com/en/model-studio/text-to-video-api-reference.
dashscope.base_http_api_url = 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1'
# If no environment variable is configured, replace with your Model Studio API key: api_key="sk-xxx".
# API keys vary by region. For more information, see https://help.aliyun.com/en/model-studio/get-api-key.
api_key = os.getenv("DASHSCOPE_API_KEY")
def sample_async_call_t2v():
# Call the asynchronous API and obtain task information.
# Use the task ID to check the status.
rsp = VideoSynthesis.async_call(api_key=api_key,
model='wan2.6-t2v',
prompt='An epic and cute scene. A small, adorable cartoon kitten general, wearing exquisitely detailed golden armor and a slightly oversized helmet, stands bravely on a cliff. He rides a small but heroic warhorse and says: "The long clouds of Qinghai darken the snowy mountains, a lone city gazes at Yumen Pass from afar. Through a hundred battles in the yellow sand, the golden armor is worn, but we will not return until we have broken Loulan". Below the cliff, a vast and endless army of mice with makeshift weapons is charging forward. This is a dramatic, large-scale battle scene inspired by ancient Chinese war epics. In the distance, dark clouds gather in the sky over the snowy mountains. The overall atmosphere is a comical and epic fusion of \'cute\' and \'domineering\'.',
audio_url='https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250923/hbiayh/%E4%BB%8E%E5%86%9B%E8%A1%8C.mp3',
size='1280*720',
duration=10,
negative_prompt="",
prompt_extend=True,
watermark=False,
seed=12345)
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))
# Obtain 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. This calls fetch at intervals and checks if the task is in a finished state.
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. Example of a response to a task creation request
{
"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. Example of a response to a task query request
The video URL expires in 24 hours. Please download the video before it expires.
{
"status_code": 200,
"request_id": "167f3beb-3dd0-47fe-a83c-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "5b65411f-d946-4e29-859e-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-bj.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
"submit_time": "2025-10-23 11:47:23.879",
"scheduled_time": "2025-10-23 11:47:34.351",
"end_time": "2025-10-23 11:52:35.323",
"orig_prompt": "An epic and cute scene featuring a small, adorable cartoon kitten general. Wearing exquisitely detailed golden armor and a slightly oversized helmet, he stands bravely on a cliff. He rides a small but heroic warhorse and recites: 'The long clouds of Qinghai darken the snowy mountains, a lone city gazes at Yumen Pass from afar. Through a hundred battles in the yellow sand, the golden armor is worn, but we will not return until we have broken Loulan.' Below the cliff, a vast army of mice with makeshift weapons charges forward. The scene is a dramatic, large-scale battle inspired by ancient Chinese war epics. In the distance, dark clouds gather over snowy mountains. The overall atmosphere is a comical and epic fusion of 'cute' and 'domineering'."
},
"usage": {
"video_count": 1,
"duration": 10,
"size": "1280*720",
"input_video_duration": 0,
"output_video_duration": 10,
"SR": 720
}
}Java
Ensure your DashScope Java software development kit (SDK) version is at least 2.22.14 before you run the following code.
If you use an older version, you may encounter errors such as "url error, please check url!". To update the SDK, see Install the SDK.
Set Constants.baseHttpApiUrl based on the region where the model is located:
Beijing
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
Replace {WorkspaceId} with your actual workspace ID.
Singapore
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
Replace {WorkspaceId} with your actual workspace ID.
Virginia
Constants.baseHttpApiUrl = "https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1";
Frankfurt
Constants.baseHttpApiUrl = "https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1";
Replace {WorkspaceId} with your actual workspace ID.
Synchronous invocation
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;
import java.util.HashMap;
import java.util.Map;
public class Text2Video {
static {
// This is the URL for the Beijing region. Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. For more information, see: https://help.aliyun.com/en/model-studio/text-to-video-api-reference
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
}
// If no environment variable is configured, replace this with your Model Studio API key: apiKey="sk-xxx"
// API keys vary by region. For more information, see: https://help.aliyun.com/en/model-studio/get-api-key
public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
/**
* Creates a video synthesis task and waits for its completion.
*/
public static void text2Video() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("watermark", false);
parameters.put("seed", 12345);
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.6-t2v")
.prompt("An epic and cute scene. A small, adorable cartoon kitten general, wearing exquisitely detailed golden armor and a slightly oversized helmet, stands bravely on a cliff. He rides a small but heroic warhorse and says: 'The long clouds of Qinghai darken the snowy mountains, a lone city gazes at Yumen Pass from afar. Through a hundred battles in the yellow sand, the golden armor is worn, but we will not return until we have broken Loulan'. Below the cliff, a vast and endless army of mice with makeshift weapons is charging forward. This is a dramatic, large-scale battle scene inspired by ancient Chinese war epics. In the distance, dark clouds gather in the sky over the snowy mountains. The overall atmosphere is a comical and epic fusion of 'cute' and 'domineering'.")
.audioUrl("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250923/hbiayh/%E4%BB%8E%E5%86%9B%E8%A1%8C.mp3")
.negativePrompt("")
.size("1280*720")
.duration(10)
.parameters(parameters)
.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 promptly.
{
"request_id": "c1209113-8437-424f-a386-xxxxxx",
"output": {
"task_id": "966cebcd-dedc-4962-af88-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
"orig_prompt": "An epic and cute scene. A small, adorable cartoon kitten general, wearing exquisitely detailed golden armor and a slightly oversized helmet, stands bravely on a cliff. He rides a small but heroic warhorse and says: 'The long clouds of Qinghai darken the snowy mountains, a lone city gazes at Yumen Pass from afar. Through a hundred battles in the yellow sand, the golden armor is worn through, but we will not return until we have broken Loulan'. Below the cliff, a vast and endless army of mice with makeshift weapons is charging forward. This is a dramatic, large-scale battle scene inspired by ancient Chinese war epics. In the distance, dark clouds gather in the sky over the snowy mountains. The overall atmosphere is a comical and epic fusion of 'cute' and 'domineering'.",
"submit_time": "2026-01-22 23:13:40.553",
"scheduled_time": "2026-01-22 23:13:49.415",
"end_time": "2026-01-22 23:17:56.380"
},
"usage": {
"video_count": 1,
"duration": 10.0,
"size": "1280*720",
"input_video_duration": 0,
"output_video_duration": 10,
"SR": 720
},
"status_code": 200,
"code": "",
"message": ""
}Asynchronous invocation
Request example
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisListResult;
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.task.AsyncTaskListParam;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.util.HashMap;
import java.util.Map;
public class Text2Video {
static {
// Beijing region URL. Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. For more information, see the referenced document.
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
}
// If no environment variable is configured, replace with your Model Studio API key: apiKey="sk-xxx".
// API keys vary by region. For more information, see the referenced document.
public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
/**
* Creates a video synthesis task and waits for it to complete.
*/
public static void text2Video() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("watermark", false);
parameters.put("seed", 12345);
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.6-t2v")
.prompt("An epic and cute scene. A small, adorable cartoon kitten general, wearing exquisitely detailed golden armor and a slightly oversized helmet, stands bravely on a cliff. He rides a small but heroic warhorse and says: 'The long clouds of Qinghai darken the snowy mountains, a lone city gazes at Yumen Pass from afar. Through a hundred battles in the yellow sand, the golden armor is worn, but we will not return until we have broken Loulan'. Below the cliff, a vast and endless army of mice with makeshift weapons is charging forward. This is a dramatic, large-scale battle scene inspired by ancient Chinese war epics. In the distance, dark clouds gather in the sky over the snowy mountains. The overall atmosphere is a comical and epic fusion of 'cute' and 'domineering'.")
.audioUrl("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250923/hbiayh/%E4%BB%8E%E5%86%9B%E8%A1%8C.mp3")
.negativePrompt("")
.size("1280*720")
.duration(10)
.parameters(parameters)
.build();
// Synchronous call
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("Please wait...");
// Retrieve the result
VideoSynthesisResult result = vs.wait(task, apiKey);
System.out.println(JsonUtils.toJson(result));
}
// Retrieve the task list
public static void listTask() throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
AsyncTaskListParam param = AsyncTaskListParam.builder().build();
param.setApiKey(apiKey);
VideoSynthesisListResult result = is.list(param);
System.out.println(result);
}
// Retrieve the result of a single task
public static void fetchTask(String taskId) throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
// If DASHSCOPE_API_KEY is set as an environment variable, apiKey can be null.
VideoSynthesisResult result = is.fetch(taskId, apiKey);
System.out.println(result.getOutput());
System.out.println(result.getUsage());
}
public static void main(String[] args) {
try {
text2Video();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
Response example
1. Example of a response to a task creation request.
{
"request_id": "5dbf9dc5-4f4c-9605-85ea-xxxxxxxx",
"output": {
"task_id": "7277e20e-aa01-4709-xxxxxxxx",
"task_status": "PENDING"
}
}
2. Example of a response to a task query request
The video_url is valid for 24 hours. Download promptly.
{
"request_id": "c1209113-8437-424f-a386-xxxxxx",
"output": {
"task_id": "966cebcd-dedc-4962-af88-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
"orig_prompt": "An epic and cute scene. A small, adorable cartoon kitten general, wearing exquisitely detailed golden armor and a slightly oversized helmet, stands bravely on a cliff. He rides a small but heroic warhorse and says: 'The long clouds of Qinghai darken the snowy mountains, a lone city gazes at Yumen Pass from afar. Through a hundred battles in the yellow sand, the golden armor is worn through, but we will not return until we have broken Loulan'. Below the cliff, a vast and endless army of mice with makeshift weapons is charging forward. This is a dramatic, large-scale battle scene inspired by ancient Chinese war epics. In the distance, dark clouds gather in the sky over the snowy mountains. The overall atmosphere is a comical and epic fusion of 'cute' and 'domineering'.",
"submit_time": "2026-01-22 23:13:40.553",
"scheduled_time": "2026-01-22 23:13:49.415",
"end_time": "2026-01-22 23:17:56.380"
},
"usage": {
"video_count": 1,
"duration": 10.0,
"size": "1280*720",
"input_video_duration": 0,
"output_video_duration": 10,
"SR": 720
},
"status_code": 200,
"code": "",
"message": ""
}Error codes
If the model call fails and returns an error message, see Error codes for resolution.
FAQ
Q: How do I convert a temporary video link to a permanent one?
A: You cannot convert the link directly. The correct procedure is to have your backend service retrieve the URL, download the video file, and then upload it to a permanent object storage service, such as Alibaba Cloud Object Storage Service (OSS), to generate a new, permanent access link.
Q: Can the returned video link be played directly in a browser?
A: No. You should not play the link directly in a browser because it expires after 24 hours. Instead, you should download and store the video, and then use a permanent link for playback.