Wan2.7-T2V API Reference
The Wan2.7-T2V model generates a smooth video based on a text prompt.
Related documents: User Guide
Scope
To ensure successful calls, make sure that the model, Endpoint URL, and API Key all belong to the same region. Cross-region calls will fail.
- Select Model: Go to the Model Marketplace to select a model and confirm its region.
- Select URL: Select the Endpoint URL of the corresponding region. HTTP URLs and DashScope SDK URLs are supported.
- Configure API Key: Select a region, obtain and configure the API Key, and then configure the API Key in environment variables.
- Install SDK: To make calls through an SDK, please install the DashScope SDK.
NoteThe sample code in this topic applies to the Beijing region.
ImportantAlibaba Cloud Model Studio has launched workspace-dedicated domains for the China (Beijing) and Singapore regions, which deliver superior performance and higher stability for inference requests. We recommend that you migrate to the new domains:
- China (Beijing) region: migrate from
https://dashscope.aliyuncs.comtohttps://{WorkspaceId}.cn-beijing.maas.aliyuncs.com - Singapore region: migrate from
https://dashscope-intl.aliyuncs.comtohttps://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
Among them, {WorkspaceId} is your workspace ID, which you can view on the Workspace Details page in the Alibaba Cloud Model Studio console. The existing domain remains available.
HTTP calls
ImportantThis API uses the new protocol and supports only the wan2.7 model.
T2V tasks take a long time to complete (usually 1 to 5 minutes), so the API uses asynchronous calls. The entire process consists of two core steps: "Create a task -> poll for the result", as follows:
Step 1: Create a task and obtain 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.
Request parametersRequest HeadersContent-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 Asynchronous processing configuration parameter. HTTP requests only support asynchronous mode, and it 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 The model name. For available models, see Models. Example values: 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 and setting a reasonable query interval (such as 15 seconds) to obtain the result.
- Task status flow: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- Result link: A video URL is returned after the task succeeds, valid for 24 hours. We recommend downloading it immediately and transferring it to permanent storage (such as Alibaba Cloud OSS).
- task_id validity: 24 hours. After it expires, 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 configuring asynchronous task callbacks.
- More operations: For operations such as batch queries and task cancellation, 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 no earlier than 2.0.1 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 import DashScopeError
# 以下为华北2(北京)地域的配置。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的region取值不同。
client = dashscope.Client(
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
# 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="cn-beijing",
)
def sample_sync_call_t2v():
# generate 为一步式调用(提交任务并等待完成),返回已完成的 Job
print('please wait...')
try:
# audio_url / negative_prompt 为 input 段字段,不在具名签名内,经 extra_input 透传
job = client.videos.generate(model='wan2.7-t2v-2026-06-12',
prompt='一幅史诗级可爱的场景。一只小巧可爱的卡通小猫将军,身穿细节精致的金色盔甲,头戴一个稍大的头盔,勇敢地站在悬崖上。他骑着一匹虽小但英勇的战马,说:"青海长云暗雪山,孤城遥望玉门关。黄沙百战穿金甲,不破楼兰终不还。"。悬崖下方,一支由老鼠组成的、数量庞大、无穷无尽的军队正带着临时制作的武器向前冲锋。这是一个戏剧性的、大规模的战斗场景,灵感来自中国古代的战争史诗。远处的雪山上空,天空乌云密布。整体氛围是"可爱"与"霸气"的搞笑和史诗般的融合。',
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返回码:{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_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 import DashScopeError
# 以下为华北2(北京)地域的配置。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的region取值不同。
client = dashscope.Client(
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
# 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/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 为 input 段字段,不在具名签名内,经 extra_input 透传
job = client.videos.jobs.create(model='wan2.7-t2v-2026-06-12',
prompt='一幅史诗级可爱的场景。一只小巧可爱的卡通小猫将军,身穿细节精致的金色盔甲,头戴一个稍大的头盔,勇敢地站在悬崖上。他骑着一匹虽小但英勇的战马,说:"青海长云暗雪山,孤城遥望玉门关。黄沙百战穿金甲,不破楼兰终不还。"。悬崖下方,一支由老鼠组成的、数量庞大、无穷无尽的军队正带着临时制作的武器向前冲锋。这是一个戏剧性的、大规模的战斗场景,灵感来自中国古代的战争史诗。远处的雪山上空,天空乌云密布。整体氛围是"可爱"与"霸气"的搞笑和史诗般的融合。',
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返回码:{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, will call fetch interval, and check it's in finished status.
# (2.0 jobs.wait 指数退避轮询,默认总预算24小时,任务 FAILED 会抛出异常)
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 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 no earlier than 2.22.14 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 {
// 以下为北京地域url,各地域的url不同,获取url:https://help.aliyun.com/zh/model-studio/text-to-video-api-reference
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
}
// 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
// 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/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("一幅史诗级可爱的场景。一只小巧可爱的卡通小猫将军,身穿细节精致的金色盔甲,头戴一个稍大的头盔,勇敢地站在悬崖上。他骑着一匹虽小但英勇的战马,说:”青海长云暗雪山,孤城遥望玉门关。黄沙百战穿金甲,不破楼兰终不还。“。悬崖下方,一支由老鼠组成的、数量庞大、无穷无尽的军队正带着临时制作的武器向前冲锋。这是一个戏剧性的、大规模的战斗场景,灵感来自中国古代的战争史诗。远处的雪山上空,天空乌云密布。整体氛围是可爱与霸气的搞笑和史诗般的融合。")
.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": "一幅史诗级可爱的场景。一只小巧可爱的卡通小猫将军,身穿细节精致的金色盔甲,头戴一个稍大的头盔,勇敢地站在悬崖上。他骑着一匹虽小但英勇的战马,说:"青海长云暗雪山,孤城遥望玉门关。黄沙百战穿金甲,不破楼兰终不还。"。悬崖下方,一支由老鼠组成的、数量庞大、无穷无尽的军队正带着临时制作的武器向前冲锋。这是一个戏剧性的、大规模的战斗场景,灵感来自中国古代的战争史诗。远处的雪山上空,天空乌云密布。整体氛围是"可爱"与"霸气"的搞笑和史诗般的融合。",
"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 {
// 以下为北京地域url,各地域的url不同,获取url:https://help.aliyun.com/zh/model-studio/text-to-video-api-reference
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
}
// 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
// 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/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("一幅史诗级可爱的场景。一只小巧可爱的卡通小猫将军,身穿细节精致的金色盔甲,头戴一个稍大的头盔,勇敢地站在悬崖上。他骑着一匹虽小但英勇的战马,说:”青海长云暗雪山,孤城遥望玉门关。黄沙百战穿金甲,不破楼兰终不还。“。悬崖下方,一支由老鼠组成的、数量庞大、无穷无尽的军队正带着临时制作的武器向前冲锋。这是一个戏剧性的、大规模的战斗场景,灵感来自中国古代的战争史诗。远处的雪山上空,天空乌云密布。整体氛围是可爱与霸气的搞笑和史诗般的融合。")
.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();
// 异步调用
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 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);
}
// 获取单个任务结果
public static void fetchTask(String taskId) throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
// 如果已设置 DASHSCOPE_API_KEY 为环境变量,apiKey 可为空
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": "一幅史诗级可爱的场景。一只小巧可爱的卡通小猫将军,身穿细节精致的金色盔甲,头戴一个稍大的头盔,勇敢地站在悬崖上。他骑着一匹虽小但英勇的战马,说:"青海长云暗雪山,孤城遥望玉门关。黄沙百战穿金甲,不破楼兰终不还。"。悬崖下方,一支由老鼠组成的、数量庞大、无穷无尽的军队正带着临时制作的武器向前冲锋。这是一个戏剧性的、大规模的战斗场景,灵感来自中国古代的战争史诗。远处的雪山上空,天空乌云密布。整体氛围是"可爱"与"霸气"的搞笑和史诗般的融合。",
"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.