The Wan text-to-video model generates smooth videos from text prompts .
References: User guide
Match the region for your model, endpoint URL, and API key. Cross-region calls fail.
Text-to-video tasks take 1–5 minutes. The API uses asynchronous invocation: Create a task → Poll for the result.
Replace
Replace
Text-to-video tasks take 1–5 minutes, so the API uses asynchronous invocation: Create a task → Poll for the result.
Replace
Replace
SDK parameter names mostly match the HTTP API, with structures following language-specific conventions.
Text-to-video tasks take 1–5 minutes. The SDK wraps the asynchronous HTTP call flow and supports both synchronous and asynchronous invocation.
Set dashscope.base_http_api_url to the region endpoint:
Replace
Set Constants.baseHttpApiUrl to the region endpoint:
Replace
If the model call fails and returns an error message, see Error codes for resolution.
A: Two changes are required:
A: Direct conversion is not possible. Download the video from the URL, then upload it to persistent storage (such as Alibaba Cloud OSS) to generate a permanent link.
A: No. The link expires after 24 hours. Download the video, store it persistently, and use a permanent link for playback.
Availability
Match the region for your model, endpoint URL, and API key. Cross-region calls fail.
- Select a model: Go to Model Square to select a model and verify its region.
- Select a URL: Use the endpoint URL for the corresponding region. HTTP and HTTPS are both supported.
- Configure an API key: Select a region, get an API key, and configure it in environment variables.
- Install the SDK: To call the API through an SDK, install the DashScope SDK.
Sample code in this topic uses the Singapore region.
HTTP (wan2.7)
Text-to-video tasks take 1–5 minutes. The API uses asynchronous invocation: Create a task → Poll for the result.
Step 1: Create a task
- Beijing
- Singapore
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis- Singapore
- Beijing
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, 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 |
Control shot structure with natural language in the prompt. The shot_type parameter has no effect.
| ||||||||||||||||||||||||
Headers | |||||||||||||||||||||||||
Content-Type string (Required)The content type of the request. Must be application/json. | |||||||||||||||||||||||||
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. | |||||||||||||||||||||||||
X-DashScope-Async string (Required)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be enable. | |||||||||||||||||||||||||
Request body | |||||||||||||||||||||||||
model string (Required)Model name. For models and pricing, see Model pricing.Example: wan2.7-t2v, wan2.7-t2v-2026-06-12. | |||||||||||||||||||||||||
input object (Required)Input data, including the prompt.
Properties prompt string (Required)Text prompt describing the video content and visual style.Supports Chinese and English. Each character or letter counts as one. Text beyond the limit is auto-truncated. Maximum length by model:
string (Optional)Elements to exclude from the generated video.Supports Chinese and English. Maximum 500 characters; longer text is auto-truncated.Example: low resolution, error, worst quality, low quality, deformed, extra fingers, bad proportions.audio_url string (Optional)URL of the audio file for video generation.Supported formats:
| |||||||||||||||||||||||||
parameters object (Optional)Video generation parameters: resolution, prompt rewriting, and watermark.
Properties resolution string (Optional)Resolution tier of the generated video. Controls the output clarity (total pixel count).
string (Optional)Aspect ratio of the output video.
integer (Optional)Duration of the output video, in seconds.
boolean (Optional)Enables prompt rewriting. When enabled, an LLM rewrites the input prompt to improve generation quality. Best for short prompts but adds latency.
boolean (Optional)Adds a watermark in the lower-right corner with the text "AI Generated".
integer (Optional)The random number seed must be an integer in the range [0, 2147483647].If not specified, a random seed is generated. A fixed seed improves reproducibility.Because model generation is probabilistic, the same seed does not guarantee identical results. |
Response parameters |
Save the task_id to query the task status and result. |
output objectTask output.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
| |
request_id stringUnique request identifier for tracing and troubleshooting. | |
code stringError code. Returned only for failed requests. See Error codes. | |
message stringDetailed error message. Returned only for failed requests. See Error codes. |
Step 2: Query the result
- Beijing
- Singapore
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}- Singapore
- Beijing
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}{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.
Request parameters |
Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours, Replace {WorkspaceId} with your actual workspace ID. |
Headers | |
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. | |
Path parameters | |
task_id string (Required)The ID of the task. |
Response parameters |
Video URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. |
outputobjectTask output.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.video_url stringURL of the generated video. Returned only when task_status is SUCCEEDED.Valid for 24 hours. The video is in MP4 format with H.264 encoding.orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. | |
usage objectOutput statistics. Returned only for successful tasks.
Properties duration floatTotal video duration, used for billing.Equal to output_video_duration.input_video_duration integerFixed value: 0.output_video_duration integerOutput video duration in seconds. Matches the input.duration value.SR integerResolution tier of the output video. Example: 720.ratio stringAspect ratio of the output video. Example: 16:9.video_count integerNumber of videos generated. Always 1. | |
request_id stringUnique request identifier for tracing and troubleshooting. |
HTTP (wan2.6 and earlier)
Text-to-video tasks take 1–5 minutes, so the API uses asynchronous invocation: Create a task → Poll for the result.
Step 1: Create a task
- Singapore
- Virginia
- Beijing
- Frankfurt
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, 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 |
|
Request headers | |
Content-Type string (Required)The content type of the request. Must be application/json. | |
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. | |
X-DashScope-Async string (Required)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be enable. | |
Request body | |
model string (Required)Model name. For models and pricing, see Model pricing.Example: wan2.6-t2v. | |
input object (Required)Input data, including the prompt.
Properties prompt string (Required)Text prompt describing the video content and visual style.Supports Chinese and English. Each character or letter counts as one. Text beyond the limit is auto-truncated. Maximum length by model:
string (Optional)Elements to exclude from the generated video.Supports Chinese and English. Maximum 500 characters; longer text is auto-truncated.Example: low resolution, error, worst quality, low quality, disfigured, extra fingers, bad proportions.audio_url string (Optional)Supported models: wan2.6 and wan2.5 series.URL of the audio file for video generation.Supported formats:
| |
parameters object (Optional)Video generation parameters: resolution, prompt rewriting, and watermark.
Properties size string (Optional)Output video resolution in width*height format. Defaults and valid values depend on the model:
integer (Optional)Output video duration in seconds. Valid values depend on the model:
boolean (Optional)Enables prompt rewriting. When enabled, an LLM rewrites the input prompt to improve quality. Best for short prompts but adds latency.
string (Optional)Supported models: wan2.6 models.Shot structure for the output video: one continuous shot or multiple shots with transitions.Valid values:
"prompt_extend": true is set.Priority: shot_type overrides the prompt. Setting shot_type to single produces a single-shot video even if the prompt requests multi-shot.watermark boolean (Optional)Adds a watermark in the lower-right corner with the text "AI Generated".
integer (Optional)The random number seed must be an integer in the range [0, 2147483647].If not specified, a random seed is generated. A fixed seed improves reproducibility.Because model generation is probabilistic, the same seed does not guarantee identical results. |
Response parameters |
Save the task_id to query the task status and result. |
output objectTask output.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
| |
request_id stringUnique request identifier for tracing and troubleshooting. | |
code stringError code. Returned only for failed requests. See Error codes. | |
message stringDetailed error message. Returned only for failed requests. See Error codes. |
Step 2: Query the result
- Singapore
- Virginia
- Beijing
- Frankfurt
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}{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.
Request parameters |
Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours, Replace {WorkspaceId} with your actual workspace ID. |
Headers | |
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. | |
Path parameters | |
task_id string (Required)The ID of the task. |
Response parameters |
Video URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. |
outputobjectTask output.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.video_url stringURL of the generated video. Returned only when task_status is SUCCEEDED.Valid for 24 hours. The video is in MP4 format with H.264 encoding.orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.actual_prompt stringWhen prompt_extend=true, the system rewrites the input prompt. This field contains the rewritten prompt used for generation.
stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. | |
usage objectOutput statistics. Returned only for successful tasks.
Properties video_duration integerReturned only for wan2.5 and earlier (used for billing).Duration of the output video in seconds. Valid values: 5, 10.duration floatReturned only for wan2.6 (used for billing).Total video duration. Formula: duration=input_video_duration+output_video_duration.input_video_duration integerReturned only for wan2.6. Fixed value: 0.output_video_duration integerReturned only for wan2.6.Output video duration in seconds. Matches the input.duration value.SR integerReturned only for wan2.6. Resolution tier of the output video. Example: 720.size stringReturned only for wan2.6. Output resolution in "width×height" format. Example: 1920×1080.video_ratio stringReturned only for wan2.5 and earlier. Output resolution in "width×height" format. Example: 832×480.video_count integerNumber of videos generated. Always 1. | |
request_id stringUnique request identifier for tracing and troubleshooting. |
DashScope SDK
SDK parameter names mostly match the HTTP API, with structures following language-specific conventions.
Text-to-video tasks take 1–5 minutes. The SDK wraps the asynchronous HTTP call flow and supports both synchronous and asynchronous invocation.
Actual processing time depends on queue depth and service load.
Python SDK
Set dashscope.base_http_api_url to the region endpoint:
- Beijing
- Singapore
- Virginia
dashscope.base_http_api_url = 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1'{WorkspaceId} with your actual workspace ID.
- Synchronous invocation
- Asynchronous invocation
Request example
Response example
The video_url expires after 24 hours. Download promptly.
Java SDK
Set Constants.baseHttpApiUrl to the region endpoint:
- Singapore
- Virginia
- Beijing
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";{WorkspaceId} with your actual workspace ID.
- Synchronous invocation
- Asynchronous invocation
Request example
Response example
The video_url expires after 24 hours. Download promptly.
Limitations
- Data retention: The task ID (
task_id) and video URL (video_url) expire after 24 hours. After expiry, they cannot be queried or downloaded. - Content moderation: Input and output undergo content moderation. Prohibited content triggers "IPInfringementSuspect" or "DataInspectionFailed" errors. See Error codes.
Error codes
If the model call fails and returns an error message, see Error codes for resolution.
FAQ
Q: What code changes are needed to upgrade from wan2.6 to wan2.7?
A: Two changes are required:
- Resolution control: wan2.7 replaces the
sizefield. Instead, it uses a combination ofresolution(resolution tier) andratio(aspect ratio) to define output resolution. Earlier models used thesizefield. - Shot type removal: wan2.7 drops the
shot_typefield. Describe shot structure directly in the prompt instead.
Q: How do I convert a temporary video link to a permanent one?
A: Direct conversion is not possible. Download the video from the URL, then upload it to persistent storage (such as Alibaba Cloud OSS) to generate a permanent link.
Example code: Download a video to a local device
Example code: Download a video to a local device