Wan3.0 is an All-in-One reference-based video generation model that supports Text-to-Video, Image-to-Video (first frame/first-last frame), and Reference-based Video Generation. It can generate videos up to 30 seconds long. Currently in preview.
Prerequisites
To ensure a successful API call, make sure that the model, Endpoint URL and API Key all belong to the same region. Cross-region calls will fail.
-
Select a model: Go to the Model Gallery to select a model and confirm the region it belongs to.
-
Select a URL: Select the Endpoint URL for the corresponding region.
-
Configure API Key: Select a region and Obtain an API key, then Configure API key as an environment variable.
The sample code in this topic applies to the Beijing region.
HTTP call
Since video generation tasks take a relatively long time (typically 1-5 minutes), the API uses asynchronous calls. The entire process consists of two core steps: "Create a task -> Poll for results", as described below:
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
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 |
File Reference to VideoPass in a file through the
Reference-based Video GenerationPass in reference images, videos, audio, files, or web links through
Text-to-VideoGenerate a video using only
First Frame to VideoStrictly specify the first frame image of the video using
First-Last Frame to VideoPass in both
|
Request headers (Headers) |
|
|
Content-Type The content type of the request. Must be |
|
|
Authorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. |
|
|
X-DashScope-Async Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be Important If this request header is missing, the error "current user api does not support synchronous calls" is returned. |
|
Request body (Request Body) |
|
|
model Model name. Fixed value: |
|
|
input Basic input information. Either |
|
|
parameters Video processing parameters. |
Response parameters |
Successful responseSave the Error responseTask creation failed. See Error codes. |
|
output Task output information. |
|
|
request_id Unique request identifier for tracing and troubleshooting. |
|
|
code Error code. Returned only for failed requests. See Error codes. |
|
|
message Detailed error message. Returned only for failed requests. See Error codes. |
Step 2: Query results 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}
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.RPS limit: The default RPS for the query API is 20. For higher-frequency queries or event notifications, we recommend that you configure an asynchronous task callback.
More operations: For batch queries, task cancellation, and other operations, see Manage asynchronous tasks.
Request parameters |
Query task resultsReplace |
Request headers (Headers) |
|
|
Authorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. |
|
URL path parameters (Path parameters) |
|
|
task_id The ID of the task. |
Response parameters |
Task succeededVideo URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly.
Task failedWhen a task fails,
Task query expiredThe |
|
output Task output information. |
|
|
usage Output statistics. Only counts successful results. |
|
|
request_id Unique request identifier for tracing and troubleshooting. |