Wan2.7 - text-to-video API reference
The Wan text-to-video model generates smooth videos from text prompts .
References: User guide
Availability
To ensure successful calls, make sure the model, endpoint URL, and API key all belong to the same region. Cross-region calls fail.
- Select a model: Go to Model Gallery to select a model and verify its region.
- Select a URL: Use the endpoint URL of the corresponding region. Both HTTP URLs and DashScope SDK URLs are supported.
- Configure an API key: Select a region, get and configure an API key, and then configure the API key in environment variables.
- Install the SDK: To call the API through an SDK, install the DashScope SDK.
NoteThe sample code in this topic applies to the Beijing region.
ImportantAlibaba 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.com - Singapore: from
https://dashscope-intl.aliyuncs.comtohttps://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
{WorkspaceId} is your workspace ID, which you can find on the Workspace Details page in the Alibaba Cloud Model Studio console. The existing domain remains fully functional.
HTTP invocation
ImportantThis interface uses the new protocol and supports only the wan2.7 model.
Because text-to-video tasks are time-consuming (usually 1 to 5 minutes), the API uses asynchronous invocation. The process consists of two core steps: "Create a task -> Poll for the result", as follows:
Step 1: Create a task to get the task ID
Beijing
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
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 when calling.
Note
- After the task is created, use the
task_idreturned by the API to query the result. The task_id is valid for 24 hours. Do not create duplicate tasks. Just poll for the result. - For guidance for new users, see Postman.
Request parametersHeadersContent-Type The request content type. This parameter must be set to Authorization Request authentication. The API uses an Alibaba Cloud Model Studio API key for authentication. Example: Bearer sk-xxxx. X-DashScope-Async The asynchronous processing configuration parameter. HTTP requests support only asynchronous calls and must be set to ImportantIf this request header is missing, the following error is returned: "current user api does not support synchronous calls". Request bodymodel Model name. For available models, see Model list. Example: wan2.7-t2v, wan2.7-t2v-2026-06-12. input Basic input information, such as the prompt. parameters Video processing parameters, such as setting the video resolution, enabling prompt rewriting, and adding a watermark. | Multi-shot narrativeControl the shot structure with natural language in
Provide an audio fileYou can pass a custom audio URL in the Automatic dubbingIf you do not provide Use a negative promptUse negative_prompt to exclude the "flower" element and prevent it from appearing in the video. dashscope CLIImportantThe SDK Expert interactive assistant can accomplish the same development and troubleshooting tasks in natural language. See DashScope SDK Expert.For the complete region table, see Base URL overview. |
Response parametersoutput Task output information. request_id Unique request identifier. Useful for tracing request details and troubleshooting. code The error code returned for failed requests. This parameter is not returned for successful requests. For details, see Error codes. message Detailed error information returned for failed requests. This parameter is not returned for successful requests. For details, see Error codes. | Successful responseSave the task_id for querying the task status and result. Error responseTask creation failed. See Error codes for troubleshooting. |
Step 2: Query the result by task ID
Beijing
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
Singapore
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Replace {WorkspaceId} with your actual workspace ID when calling.
Note
- Polling recommendation: Video generation takes several minutes. We recommend using a polling mechanism with a reasonable query interval (for example, 15 seconds) to obtain the result.
- Task state transitions: PENDING (queued) → RUNNING (processing) → SUCCEEDED (success) / FAILED (failure).
- Result link: After the task succeeds, a video URL is returned, valid for 24 hours. We recommend downloading the video immediately after obtaining the URL and saving it to permanent storage (such as Alibaba Cloud OSS).
- task_id validity: 24 hours. After expiration, the result can no longer be queried, and the API returns the task status as
UNKNOWN. - RPS limit: The default RPS of 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 parametersHeadersAuthorization Request authentication. The API uses an Alibaba Cloud Model Studio API key for authentication. Example: Bearer sk-xxxx. URL path parameterstask_id The task ID. | Query task resultReplace |
Response parametersoutput Task output information. usage Output statistics. Only successful results are counted. request_id Unique request identifier. Useful for tracing request details and troubleshooting. | Task executed successfullyThe video URL is retained for only 24 hours and is automatically deleted after that. Save the generated video promptly. Task execution failedIf the task fails, task_status is set to FAILED with an error code and message. See Error codes for troubleshooting. Task query expiredThe task_id is valid for queries for 24 hours. After expiration, the result can no longer be queried, and the following error is returned. |
DashScope SDK invocation
SDK parameter names are basically the same as those of the HTTP API, with parameter structures encapsulated according to the conventions of each language.
Because text-to-video tasks are time-consuming (usually 1 to 5 minutes), the SDK encapsulates the asynchronous HTTP call flow at the underlying layer and supports both synchronous and asynchronous invocation.
The actual processing time depends on the number of queued tasks and service execution. Be patient while waiting for the result.
Python SDK invocation
ImportantMake sure the DashScope Python SDK version is 2.0.1 or later before running the following code.
Set region based on the region of the model (pass it in when constructing the Client; the region value varies by region):
Beijing
region="cn-beijing"
Singapore
region="ap-southeast-1"
Replace {WorkspaceId} with your actual workspace ID when calling.
Synchronous invocation
Request example
import dashscope
import os
from dashscope.v2 import DashScopeError
# The following is the configuration for the China (Beijing) region. Replace {WorkspaceId} with your Model Studio workspace ID. The region value varies by region.
client = dashscope.Client(
# If no environment variable is configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
# API keys vary by region. Get an API key: https://help.aliyun.com/en/model-studio/get-api-key
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="cn-beijing",
)
def sample_sync_call_t2v():
# generate is a one-step call (submits the task and waits for completion) that returns a completed Job
print('please wait...')
try:
# audio_url / negative_prompt are input-section fields, not in the named signature; pass them through extra_input
job = client.videos.generate(model='wan2.7-t2v-2026-06-12',
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".',
extra_input={'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',
'negative_prompt': ""},
resolution='720P',
ratio='16:9',
duration=10,
prompt_extend=True,
watermark=False,
seed=12345)
print(job)
print(job.video_url)
except DashScopeError as e:
print(f"HTTP status code: {e.status_code}")
print(f"Error code: {e.code}")
print(f"Error message: {e.message}")
print("See the documentation: https://help.aliyun.com/en/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": "72082605-4559-9bb7-aa5c-xxxxxx",
"task_id": "43b954a2-3e86-4681-9443-xxxxxx",
"status": "SUCCEEDED",
"results": [
{
"video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxxx"
}
],
"task_metrics": {
"TOTAL": 1,
"SUCCEEDED": 1,
"FAILED": 0
},
"usage": {
"video_count": 1,
"video_duration": 0,
"video_ratio": "",
"duration": 10,
"input_video_duration": 0,
"output_video_duration": 10,
"SR": 720,
"ratio": "16:9"
}
}
Asynchronous invocation
Request example
import dashscope
import os
from dashscope.v2 import DashScopeError
# The following is the configuration for the China (Beijing) region. Replace {WorkspaceId} with your Model Studio workspace ID. The region value varies by region.
client = dashscope.Client(
# If no environment variable is configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
# API keys vary by region. Get an API key: https://help.aliyun.com/en/model-studio/get-api-key
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
# you can get task status with the returned task id.
try:
# audio_url / negative_prompt are input-section fields, not in the named signature; pass them through extra_input
job = client.videos.jobs.create(model='wan2.7-t2v-2026-06-12',
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".',
extra_input={'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',
'negative_prompt': ""},
resolution='720P',
ratio='16:9',
duration=10,
prompt_extend=True,
watermark=False,
seed=12345)
print(job)
print("task_id: %s" % job.task_id)
except DashScopeError as e:
print(f"HTTP status code: {e.status_code}")
print(f"Error code: {e.code}")
print(f"Error message: {e.message}")
print("See the documentation: https://help.aliyun.com/en/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 status code: {e.status_code}")
print(f"Error code: {e.code}")
print(f"Error message: {e.message}")
print("See the documentation: https://help.aliyun.com/en/model-studio/developer-reference/error-code")
# wait the task complete, will call fetch interval, and check it's in finished status.
# (2.0 jobs.wait uses exponential backoff polling with a default total budget of 24 hours; a FAILED task raises an exception)
try:
done = client.videos.jobs.wait(job)
print(done)
print(done.video_url)
except DashScopeError as e:
print(f"HTTP status code: {e.status_code}")
print(f"Error code: {e.code}")
print(f"Error message: {e.message}")
print("See the documentation: https://help.aliyun.com/en/model-studio/developer-reference/error-code")
if __name__ == '__main__':
sample_async_call_t2v()
Response example
- Response example for task creation
{
"request_id": "c86ff7ba-8377-917a-90ed-xxxxxx",
"task_id": "721164c6-8619-4a35-a6d9-xxxxxx",
"status": "PENDING"
}
- Response example for querying the task result
The video_url is valid for 24 hours. Download the video promptly.
{
"request_id": "72082605-4559-9bb7-aa5c-xxxxxx",
"task_id": "43b954a2-3e86-4681-9443-xxxxxx",
"status": "SUCCEEDED",
"results": [
{
"video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxxx"
}
],
"task_metrics": {
"TOTAL": 1,
"SUCCEEDED": 1,
"FAILED": 0
},
"usage": {
"video_count": 1,
"video_duration": 0,
"video_ratio": "",
"duration": 10,
"input_video_duration": 0,
"output_video_duration": 10,
"SR": 720,
"ratio": "16:9"
}
}
Java SDK invocation
ImportantMake sure the DashScope Java SDK version is 2.22.14 or later before running the following code.
Set Constants.baseHttpApiUrl based on the region of the model:
Beijing
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
Singapore
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
Replace {WorkspaceId} with your actual workspace ID when calling.
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 {
// The following is the URL for the Beijing region. 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 the following line with your Model Studio API key: api_key="sk-xxx"
// API keys vary by region. Get an API key: https://help.aliyun.com/en/model-studio/get-api-key
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("wan2.7-t2v-2026-06-12")
.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("")
.resolution("720P")
.ratio("16:9")
.duration(10)
.promptExtend(true)
.watermark(false)
.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": "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, 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-04-16 23:13:40.553",
"scheduled_time": "2026-04-16 23:13:49.415",
"end_time": "2026-04-16 23:17:56.380"
},
"usage": {
"video_count": 1,
"duration": 10.0,
"input_video_duration": 0.0,
"output_video_duration": 10.0,
"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 {
// The following is the URL for the Beijing region. 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 the following line with your Model Studio API key: api_key="sk-xxx"
// API keys vary by region. Get an API key: https://help.aliyun.com/en/model-studio/get-api-key
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("wan2.7-t2v-2026-06-12")
.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("")
.resolution("720P")
.ratio("16:9")
.duration(10)
.promptExtend(true)
.watermark(false)
.build();
// Asynchronous call
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("please wait...");
// Get the result
VideoSynthesisResult result = vs.wait(task, apiKey);
System.out.println(JsonUtils.toJson(result));
}
// Get 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);
}
// Get 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 empty
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
- Response example for task creation.
{
"request_id": "5dbf9dc5-4f4c-9605-85ea-xxxxxxxx",
"output": {
"task_id": "7277e20e-aa01-4709-xxxxxxxx",
"task_status": "PENDING"
}
}
- Response example for querying the task result
The video_url is valid for 24 hours. Download the video 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, 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-04-16 23:13:40.553",
"scheduled_time": "2026-04-16 23:13:49.415",
"end_time": "2026-04-16 23:17:56.380"
},
"usage": {
"video_count": 1,
"duration": 10.0,
"input_video_duration": 0.0,
"output_video_duration": 10.0,
"SR": "720"
},
"status_code": 200,
"code": "",
"message": ""
}
Error codes
If the model call fails and returns an error message, see Error codes for troubleshooting.
FAQ
Q: What code changes are required to upgrade from wan2.6 to wan2.7?
A: There are two main changes. Adjust these parameters during migration:
- Change how the output video resolution is controlled: wan2.7 no longer uses the
sizefield. Instead, the output video resolution is defined by combiningresolution(resolution tier) andratio(aspect ratio). Earlier models used thesizefield directly. - Shot type field removed: wan2.7 no longer supports the
shot_typefield, which is deprecated. Describe the shot type directly in the prompt. Earlier models supported controlling the shot type through this field.