The Wan2.7 text-to-video model generates a smooth video based on a text prompt.
Related documents: User Guide
To ensure successful calls, make sure that the model, Endpoint URL, and API Key belong to the same region. Cross-region calls will fail.
Because text-to-video tasks take a long time to complete (typically 1 to 5 minutes), the API uses asynchronous calls. The overall process consists of two core steps: "create a task -> poll for the result", as follows:
When making calls, replace
When making calls, replace
The parameter naming of the SDK is basically the same as that of the HTTP interface, and the parameter structure is encapsulated according to the characteristics of each language.
Since T2V tasks take a long time (usually 1-5 minutes), the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous calling methods.
Set
When making calls, replace
Set
When making calls, replace
If the model call fails and returns an error message, see Error codes for troubleshooting.
A: There are mainly two changes, and you need to adjust the parameters during migration:
Scope
To ensure successful calls, make sure that the model, Endpoint URL, and API Key belong to the same region. Cross-region calls will fail.
- Select Model: Go to Model Studio 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 and obtain and configure an API Key, and then configure the API Key as an environment variable.
- Install SDK: To make calls through an SDK, install the DashScope SDK.
The sample code in this document applies to the Singapore region.
HTTP invocation
Because text-to-video tasks take a long time to complete (typically 1 to 5 minutes), the API uses asynchronous calls. The overall 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
- Singapore
- Beijing
- dashscope CLI
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis{WorkspaceId} with your actual workspace ID.
- 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; just poll for the result. - For a beginner's guide, see Postman.
Request parametersRequest headers (Headers)Content-Typestring(Required)The request content type. This parameter must be set to application/json.Authorizationstring(Required)Request authentication. The API uses the Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.X-DashScope-Asyncstring(Required)Asynchronous processing configuration parameter. HTTP requests support asynchronous calls only and must be set toenable.Request Bodymodelstring (Required)Model name. For available models, see the Models.Example values: wan2.7-t2v, wan2.7-t2v-2026-06-12.input object (Required)Basic input information, such as prompts.
Property prompt string (Required)The text prompt. It describes the elements and visual features that you want to include in the generated video.Both Chinese and English are supported. Each Chinese character or letter counts as one character, and any excess is automatically truncated. The length limit varies by model version:
string (Optional)The negative prompt, which describes content that you do not want to see in the video, and can be used to constrain the video visuals.Both Chinese and English are supported. The length must not exceed 500 characters, and any excess is automatically truncated.Example values: low resolution, fault, worst quality, low quality, incomplete, extra fingers, bad proportions, etc.audio_url string (Optional)The audio file URL. The model uses this audio to generate the video.Supported input formats:
object (Optional)Video processing parameters, such as setting the video resolution, enabling prompt smart rewriting, and adding a watermark.
Property resolution string (Optional)The resolution tier of the generated video, which is used to control the video clarity (total pixels).
string (Optional)The aspect ratio of the generated video.
integer (Optional)The duration of the generated video, in seconds.
boolean (Optional)Whether to enable intelligent prompt rewriting. When enabled, a large model is used to intelligently rewrite the input prompt. It significantly improves the generation result for short prompts, but increases the processing time.
boolean (Optional)Whether to add a watermark. The watermark is located in the lower-right corner of the video, with the fixed text "AI-generated".
integer (Optional)The random seed, with a value range of [0, 2147483647].If not specified, the system automatically generates a random seed. To improve the reproducibility of the generation result, it is recommended to use a fixed seed value.Note that model generation is probabilistic: even with the same seed, the generation result is not guaranteed to be exactly the same each time. |
The shot structure is controlled through natural language in the prompt. The shot_type parameter is not required, and it has no effect even if configured.
|
Response parametersoutputobjectnode output information.
Property task_id stringnode ID. The validity period for queries is 24 hours.task_status stringnode status.
Enum values
stringThe unique request identifier. It can be used for request detail tracing and troubleshooting.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringDetailed error information returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes. |
Please save the task_id to query the node status and results. |
Step 2: Query results by node ID
- Singapore
- Beijing
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}{WorkspaceId} with your actual workspace ID.
- Polling recommendations: Video generation takes several minutes. We recommend using the polling mechanism and setting a reasonable query interval (for example, 15 seconds) to obtain the results.
- Node status transitions: PENDING (queuing) → RUNNING (processing) → SUCCEEDED (success) / FAILED (failed).
- Result link: After the node succeeds, the video URL is returned and is valid for 24 hours. We recommend that you download the video immediately after obtaining the link and save it to permanent storage (such as Alibaba Cloud OSS).
- task_id validity: 24 hours. After the timeout, results can no longer be queried, and the API returns the node status as
UNKNOWN.
Request parametersHeadersAuthorizationstring(Required)Request authentication. The API uses the Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.URL path parameterstask_idstring (required)node ID. |
Replace {task_id} entirely with the value of task_id returned by the API in the previous step. The validity period for task_id queries is 24 hours. Also replace {WorkspaceId} with the actual workspace ID. |
Response parametersoutputobjectnode output information.
Property task_id stringnode ID. The validity period for queries is 24 hours.task_status stringnode status.
Enum values
stringThe time when the node was submitted. The time zone is UTC+8, in the format YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringTask execution time. The time zone is UTC+8, and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringTask completion time. The time zone is UTC+8, and the format is YYYY-MM-DD HH:mm:ss.SSS.video_urlstringThe video URL. Returned only when task_status is SUCCEEDED.The link is valid for 24 hours, and you can download the video from this URL. The video format is MP4 (H.264 encoding).orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringDetailed error information returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.objectOutput information statistics. Only successful results are counted.
Property duration floatThe total video duration of the output video, used for billing.Among them, duration=output_video_duration.input_video_duration integerFixed to 0.output_video_duration integerThe duration of the output video, in seconds. Its value is equal to the value of input.duration.SR integerThe resolution tier of the generated video. Example value: 720.ratio stringThe aspect ratio of the generated video. Example value: 16:9.video_count integerThe number of generated videos. Fixed to 1.stringThe unique request identifier. It can be used for request detail tracing and troubleshooting. |
The video URL is retained for only 24 hours and will be automatically cleared after the timeout. Please save the generated video in a timely manner. |
DashScope SDK calls
The parameter naming of the SDK is basically the same as that of the HTTP interface, and the parameter structure is encapsulated according to the characteristics of each language.
Since T2V tasks take a long time (usually 1-5 minutes), the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous calling methods.
The specific time consumption depends on the number of queued tasks and service execution conditions. Please wait patiently when obtaining the results.
Python SDK calls
Set region based on the region where the model is located (pass it in when constructing the Client; the region value varies by region):
- Singapore
- Beijing
region="ap-southeast-1"{WorkspaceId} with your actual workspace ID.
- Synchronous Call
- Asynchronous Call
Request example
Response example
The video_url is valid for 24 hours. Please download the video in a timely manner.
Java SDK invocation
Set Constants.baseHttpApiUrl based on the region where the model is located:
- Singapore
- Beijing
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";{WorkspaceId} with your actual workspace ID.
- Synchronous Call
- Asynchronous Call
Request example
Response example
The video_url is valid for 24 hours. Please download the video in a timely manner.
Error codes
If the model call fails and returns an error message, see Error codes for troubleshooting.
FAQ
Q: When upgrading from wan2.6 to wan2.7, what changes do I need to make in the code?
A: There are mainly two changes, and you need to adjust the parameters during migration:
- Change in how the output video resolution is controlled: wan2.7 no longer uses the
sizefield; instead, it defines the output video resolution by combining theresolution(resolution tier) andratio(aspect ratio) fields, while earlier models use thesizefield directly. - Removal of the shot type field: wan2.7 no longer supports the
shot_typefield. This parameter is deprecated, and you can describe the shot type directly in the prompt; earlier models support controlling the shot type through this field.