The Wan2.7-T2V 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 all belong to the same region. Cross-region calls will fail.
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:
Replace
Replace
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.
Set
Replace
Set
Replace
If the model call fails and returns an error message, see Error codes for troubleshooting.
A: There are two main changes. Adjust these parameters during migration:
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.
The sample code in this topic applies to the Beijing region.
HTTP calls
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
- Singapore
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis{WorkspaceId} with your actual workspace ID when calling.
- 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 a beginner's guide, see Postman.
Request parametersRequest HeadersContent-Typestring(Required)The request content type. This parameter must be set to application/json.Authorizationstring(Required)Request authentication. The API uses an Alibaba Cloud Model Studio API key for authentication. Example: Bearer sk-xxxx.X-DashScope-Asyncstring(Required)Asynchronous processing configuration parameter. HTTP requests only support asynchronous mode, and it must be set to enable.Request Bodymodelstring (Required)The model name. For available models, see Models.Example values: wan2.7-t2v, wan2.7-t2v-2026-06-12.input object (required)Basic input information, such as the prompt.
Properties prompt string (required)The text prompt. It describes the elements and visual features you expect in the generated video.Supports Chinese and English. 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 you do not want to see in the video and constrains the video output.Supports Chinese and English, with a maximum length of 500 characters; any excess is automatically truncated.Example values: low resolution, fault, worst quality, low quality, incomplete, extra fingers, poor 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 rewriting, and adding a watermark.
Properties resolution string (Optional)The resolution tier of the generated video, which controls 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 prompt rewriting. When enabled, an LLM rewrites the input prompt. This significantly improves generation quality for short prompts but increases processing time.
boolean (Optional)Whether to add a watermark. The watermark is in the lower-right corner of the video with the fixed text "AI Generated".
integer (Optional)The random number seed, in the range [0, 2147483647].If not specified, the system generates a random seed. To improve the reproducibility of generation results, use a fixed seed value.Note that model generation is probabilistic. Even with the same seed, identical results are not guaranteed each time. |
Control the shot structure with natural language in prompt. There is no need to set the shot_type parameter, and setting it has no effect.
|
Response parametersoutputobjectTask output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe task status.
Enumeration values
stringUnique request identifier. Useful for tracing request details and troubleshooting.codestringThe error code returned for failed requests. This parameter is not returned for successful requests. For details, see Error codes.messagestringDetailed error information returned for failed requests. This parameter is not returned for successful requests. For details, see Error codes. |
Save the task_id for querying the task status and result. |
Step 2: Query the result by task ID
- Beijing
- Singapore
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}{WorkspaceId} with your actual workspace ID when calling.
- 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 parametersHeadersAuthorizationstring(Required)Request authentication. The API uses an Alibaba Cloud Model Studio API key for authentication. Example: Bearer sk-xxxx.URL path parameterstask_idstring(Required)The task ID. |
Replace {task_id} with the exact task_id value returned by the previous API call. The task_id is valid for queries for 24 hours. Also replace {WorkspaceId} with your actual workspace ID. |
Response parametersoutputobjectTask output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe task status.
Enumeration values
stringThe task submission time. The format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe task execution time. The format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe task completion time. 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 can be used to download the video. The video format is MP4 (H.264 encoding).orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.codestringThe error code returned for failed requests. This parameter is not returned for successful requests. For details, see Error codes.messagestringDetailed error information returned for failed requests. This parameter is not returned for successful requests. For details, see Error codes.objectOutput statistics. Only successful results are counted.
Properties duration floatThe total duration of the output video, used for billing.Specifically, duration=output_video_duration.input_video_duration integerFixed at 0.output_video_duration integerThe duration of the output video, in seconds. Equal to the value of input.duration.SR integerThe resolution tier of the generated video. Example: 720.ratio stringThe aspect ratio of the generated video. Example: 16:9.video_count integerThe number of videos generated. Fixed at 1.stringUnique request identifier. Useful for tracing request details and troubleshooting. |
The video URL is retained for only 24 hours and is automatically deleted after that. Save the generated video promptly. |
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
Set region based on the region of the model (pass it in when constructing the Client; the region value varies by region):
- Beijing
- Singapore
region="cn-beijing"{WorkspaceId} with your actual workspace ID when calling.
- Synchronous invocation
- Asynchronous invocation
Request example
Response example
The video_url is valid for 24 hours. Download the video promptly.
Java SDK invocation
Set Constants.baseHttpApiUrl based on the region of the model:
- Beijing
- Singapore
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";{WorkspaceId} with your actual workspace ID when calling.
- Synchronous invocation
- Asynchronous invocation
Request example
Response example
The video_url is valid for 24 hours. Download the video promptly.
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.