The Wan-T2V model generates a smooth video based on a text prompt.
Related documentation: 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.
Since T2V tasks take a long time to complete (typically 1 to 5 minutes), the API uses asynchronous calls. The entire process consists of two core steps: "Create Task -> Poll for Results", as follows:
The SDK parameter naming is basically the same as that of the HTTP API, and the parameter structure is encapsulated according to the characteristics of each language.
Since T2V tasks are time-consuming (usually 1-5 minutes), the SDK encapsulates the HTTP asynchronous invocation process at the underlying layer, supporting both synchronous and asynchronous calling methods.
Set
Set
If the model call fails and returns an error message, see Error codes to resolve the issue.
A: You cannot convert the link directly. The correct approach is: after the backend service obtains the URL, download the video file via code, then upload it to a permanent object storage service (such as Alibaba Cloud OSS) to generate a new, permanently accessible link.
A: This is not recommended, because the link expires after 24 hours. The best practice is to have the backend download and transfer the video first, then use a permanent link for video playback.
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: Confirm the region that the model belongs to.
- 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, 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 call
Since T2V tasks take a long time to complete (typically 1 to 5 minutes), the API uses asynchronous calls. The entire process consists of two core steps: "Create Task -> Poll for Results", as follows:
Step 1: Create a task to obtain the task ID
- Singapore
- Virginia
- Frankfurt
- Beijing
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesisWhen calling the API, replace {WorkspaceId} with the 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 same task repeatedly; simply poll for the result. - For a beginner's guide, see Postman.
Request parametersRequest headersContent-Typestring(required)Request content type. This parameter must be set to application/json.Authorizationstring(required)Request authentication. This API uses an 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 the value must be set to enable.Request Bodymodelstring (Required)Model name. For available models, see Models.Example value: wan2.6-t2v.input object (Required)Basic input information, such as the prompt.
Property prompt string (Required)Text prompt. Describes the elements and visual features that you want 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)Negative prompt, used to describe content that you do not want to see in the video, which constrains the video visuals.Supports Chinese and English, with a length of no more than 500 characters; any excess is automatically truncated.Example value: low resolution, fault, worst quality, low quality, deformed, extra fingers, bad proportions, etc.audio_url string (Optional)Supported models: wan2.6 and wan2.5 series models.The URL of the audio file. The model uses this audio to generate the video.Supported input formats:
object (Optional)Image processing parameters, such as setting the video resolution, enabling intelligent prompt rewriting, and adding a watermark.
Property size string (Optional)Specifies the resolution of the generated video, in the format width*height. The default value and available enumeration values of this parameter depend on the model parameter, as follows:
integer (Optional)The duration of the generated video, in seconds. The values of this parameter depend on the model parameter:
boolean (Optional)Specifies whether to enable intelligent prompt rewriting. When enabled, a large model is used to intelligently rewrite the input prompt. This significantly improves generation results for short prompts, but increases processing time.
string (Optional)Supported models: wan2.6 models.Specifies the shot type of the generated video, that is, whether the video consists of a single continuous shot or multiple switching shots.Available values:
"prompt_extend": true.Parameter priority: shot_type > prompt. For example, if shot_type is set to "single", even if the prompt contains "generate a multi-shot video", the model still outputs a single-shot video.watermark boolean (Optional)Specifies whether to add a watermark. The watermark is located in the lower-right corner of the video, with fixed text "AI generated".
integer (Optional)The random number seed, in the range [0, 2147483647].If not specified, the system automatically generates a random seed. To improve the reproducibility of generation results, it is recommended to fix the seed value.Note that, due to the probabilistic nature of model generation, even with the same seed, identical generation results cannot be guaranteed each time. |
|
Response parametersoutputobjectThe task output information.
Property task_id stringTask ID. The query validity period is 24 hours.task_status stringTask status.
Enumerated values
stringThe unique request identifier. It can be used for tracing request details and troubleshooting.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed 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, which is used to query the task status and results. |
Step 2: Query results by task ID
- Singapore
- Virginia
- Frankfurt
- Beijing
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}When calling the API, replace {WorkspaceId} with the actual workspace ID.- 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 results.
- Task status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- Result link: After the task succeeds, a video link is returned, valid for 24 hours. We recommend downloading the file immediately after obtaining the link and storing it in permanent storage (such as Alibaba Cloud OSS).
- task_id validity: 24 hours. After it expires, results can no longer be queried, and the API will return the task status as
UNKNOWN.
Request parametersHeadersAuthorizationstring(required)Request authentication. This API uses an Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.Path parameterstask_idstring(Required)The task ID. |
Replace {task_id} with the value of task_id returned by the API in the previous step. The task_id is valid for query within 24 hours, and replace {WorkspaceId} with your actual Workspace ID. |
Response parametersoutputobjectThe task output information.
Property task_id stringTask ID. The query validity period is 24 hours.task_status stringTask status.
Enumerated values
stringTask submission time. 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, in the format YYYY-MM-DD HH:mm:ss.SSS.end_time stringTask completion time. The time zone is UTC+8, in the format 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 through this URL. The video format is MP4 (H.264 encoding).orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.actual_prompt stringWhen prompt_extend=true, the system intelligently rewrites the input prompt. This field returns the optimized prompt actually used for generation.
stringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed 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 video_duration integerReturned only when using wan2.5 or earlier models, used for billing.The duration of the generated video, in seconds. Enumerated values: 5 and 10.duration floatReturned only when using wan2.6 models, used for billing.Indicates the total video duration, where duration=input_video_duration+output_video_duration.input_video_duration integerReturned only when using wan2.6 models. Fixed at 0.output_video_duration integerReturned only when using wan2.6 models.The duration of the output video, in seconds. Its value is equal to the value of input.duration.SR integerReturned only when using wan2.6 models. The resolution tier of the generated video. Example value: 720.size stringReturned only when using wan2.6 models. The resolution of the generated video. The format is "widthheight". Example value: 19201080.video_ratio stringReturned only for wan2.5 or earlier models. The resolution of the generated video. The format is "widthheight". Example value: 832480.video_count integerThe number of generated videos. Fixed at 1.stringThe unique request identifier. It can be used for tracing request details and troubleshooting. |
The video URL is retained for only 24 hours and is automatically cleared after expiration. Save the generated video in a timely manner. |
DashScope SDK Calls
The SDK parameter naming is basically the same as that of the HTTP API, and the parameter structure is encapsulated according to the characteristics of each language.
Since T2V tasks are time-consuming (usually 1-5 minutes), the SDK encapsulates the HTTP asynchronous invocation process at the underlying layer, supporting both synchronous and asynchronous calling methods.
The actual execution time depends on the number of queued tasks and the service execution status. 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
- Virginia
- Frankfurt
region="ap-southeast-1"When calling the API, replace {WorkspaceId} with the actual workspace ID.- Synchronous call
- Asynchronous call
Sample request
Sample response
video_url is valid for 24 hours. Download the video in a timely manner.
Java SDK Calls
Set Constants.baseHttpApiUrl based on the region where the model is located:
- Singapore
- Virginia
- Beijing
- Frankfurt
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";When calling the API, replace {WorkspaceId} with the actual workspace ID.- Synchronous call
- Asynchronous call
Sample request
Sample response
video_url is valid for 24 hours. Download the video in a timely manner.
Error codes
If the model call fails and returns an error message, see Error codes to resolve the issue.
FAQ
Q: How do I convert a temporary video link to a permanent link?
A: You cannot convert the link directly. The correct approach is: after the backend service obtains the URL, download the video file via code, then upload it to a permanent object storage service (such as Alibaba Cloud OSS) to generate a new, permanently accessible link.
Sample code: Download the video to local
Sample code: Download the video to local