The Wan reference-to-video model accepts multimodal input and generates single-character or multi-character interaction videos using people or objects as protagonists.
See also: User guide
The model, endpoint URL, and API key must belong to the same region. Cross-region calls will fail.
Video generation tasks typically take 1–5 minutes. The API uses asynchronous calls with two steps: "create a task -> poll for the result". Details are as follows:
SDK parameters follow the same naming conventions as the HTTP API, with language-specific wrappers.
Reference-to-video tasks typically take 1–5 minutes. The SDK wraps the HTTP asynchronous workflow and supports both synchronous and asynchronous calls.
Set
Set
If the model call fails and returns an error message, see Error codes for resolution.
Availability
The model, endpoint URL, and API key must belong to the same region. Cross-region calls will fail.
- Select a model: Confirm the region of the model.
- Select a URL: Use the endpoint URL for the corresponding region. HTTP URLs are supported.
- 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 China (Beijing) region.
HTTP
Video generation tasks typically take 1–5 minutes. The API uses asynchronous calls with two steps: "create a task -> poll for the result". Details are as follows:
Step 1: Create a task
- China (Beijing)
- Singapore
- US (Virginia)
- Frankfurt
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesisReplace {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; use polling to obtain the result. - For a beginner's guide, see Postman.
Request parametersHeadersContent-Typestring (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)Asynchronous processing configuration parameter. HTTP requests support asynchronous mode only, and it must be set to enable.Request bodymodelstring (Required)The model to use. See Model pricing for available models and pricing.Example: wan2.6-r2v-flash.input object (Required)Input parameters such as the prompt.
Properties prompt string (Required)Text prompt describing the desired elements and visual characteristics of the generated video.Supports Chinese and English. Each character counts as one. Content exceeding the limit is automatically truncated.
string (Optional)Negative prompt describing unwanted elements in the video.Supports Chinese and English. Maximum length: 500 characters. Content exceeding the limit is automatically truncated.Example: low resolution, errors, worst quality, low quality, incomplete, extra fingers, poor proportions, etc.reference_urls array[string] (Required)Array of reference file URLs. Supports both video and image inputs. Used to extract character appearance and voice (if available) to generate videos that match the reference characteristics.
Deprecated reference_video_urls array[string]Array of reference video URLs. Used to extract character appearance and voice (if available) to generate videos that match the reference characteristics.
object (Optional)Video generation parameters such as resolution, prompt rewriting, and watermark.
Properties size string (Optional)Resolution of the generated video, in width*height format. The default value and available options depend on the model parameter:
integer (Optional)Duration of the generated video, in seconds.
string (Optional)Shot composition of the generated video, determining whether the video consists of a single continuous shot or multiple shots.Parameter priority: shot_type > prompt. For example, if shot_type is set to "single", the model outputs a single-shot video even if the prompt says "generate a multi-shot video".Valid values:
Use this parameter to control the narrative structure of the video, such as single-shot for product showcases or multi-shot for story clips. boolean (Optional)Supported model: wan2.6-r2v-flash.Whether to generate audio in the video.Valid values:
boolean (Optional)Whether to add a watermark. The watermark appears in the bottom-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. |
Pass image and video URLs through reference_urls. Set shot_type to multi for multi-shot video. |
Response parametersoutputobjectTask output.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringUnique request identifier for tracing and troubleshooting.codestringError code. Returned only for failed requests. See Error codes.messagestringDetailed error message. Returned only for failed requests. See Error codes. |
Save the task_id for querying the task status and result. |
Step 2: Retrieve task result
- China (Beijing)
- Singapore
- US (Virginia)
- Frankfurt
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}Replace {WorkspaceId} with your actual workspace ID.- Polling recommendation: Video generation takes several minutes. We recommend using a polling mechanism with a reasonable query interval (such as 15 seconds) to obtain the result.
- Task status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- Result link: After the task succeeds, a video URL is returned, valid for 24 hours. We recommend downloading the video immediately after obtaining the URL and storing it in 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
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 batch queries, task cancellation, and other operations, see Manage asynchronous tasks.
Request parametersHeadersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.Path parameterstask_idstring (Required)The ID of the task. |
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. |
Response parametersoutputobjectTask output.
Properties task_id string (Required)The ID of the task.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. format is YYYY-MM-DD HH:mm:ss.SSS.video_urlstringThe video URL. 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.codestringError code. Returned only for failed requests. See Error codes.messagestringDetailed error message. Returned only for failed requests. See Error codes.objectUsage statistics. Only counts successful results.
Properties input_video_duration integerDuration of the input reference video, in seconds.output_video_duration integerDuration of the output video, in seconds.duration floatTotal video duration. Billing is based on this value.Formula: duration = input_video_duration + output_video_duration.SR integerResolution tier of the generated video. Example: 720.sizestringThe resolution of the generated video. The format is "widthheight"; example value: 1280720.video_count integerNumber of generated videos. Always 1.stringUnique request identifier for tracing and troubleshooting. |
Video URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. |
DashScope SDK
SDK parameters follow the same naming conventions as the HTTP API, with language-specific wrappers.
Reference-to-video tasks typically take 1–5 minutes. The SDK wraps the HTTP asynchronous workflow and supports both synchronous and asynchronous calls.
Actual processing time depends on the task queue and server load.
Python
Set region based on the model's region (passed in when constructing the Client; the region value varies by region):
- China (Beijing)
- Singapore
- US (Virginia)
- Frankfurt
region="cn-beijing"Replace {WorkspaceId} with your actual workspace ID.- Synchronous
- Asynchronous
Synchronous calls block until video generation completes and the result is returned.
Request example
Java
Set baseHttpApiUrl based on the model's region:
- China (Beijing)
- Singapore
- Frankfurt
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";Replace {WorkspaceId} with your actual workspace ID.- Synchronous
- Asynchronous
Synchronous calls block until video generation completes and the result is returned.