Wan-R2V accepts multimodal input (images, videos, and audio) to generate videos featuring one or more characters while preserving their appearance and voice across scenes.
References: User guide
To ensure successful API calls, the model, endpoint URL, and API key must all belong to the same region. Cross-region calls will fail.
Video generation typically takes 1 to 5 minutes, so the API uses asynchronous invocation. The workflow has two steps: create a task, then poll for the result.
Replace
Replace
SDK parameter names are largely consistent with the HTTP API. The parameter structure is encapsulated based on language features.
Reference-to-video tasks typically take 1 to 5 minutes. The SDK wraps the HTTP asynchronous flow and supports both synchronous and asynchronous calls.
Set base_http_api_url based on the model's region:
Replace
Set baseHttpApiUrl based on the model's region:
Replace
If the model call fails and returns an error message, see Error codes for resolution.
Only wan2.7 supports voice reference. In the
Availability
To ensure successful API calls, the model, endpoint URL, and API key must all belong to the same region. Cross-region calls will fail.
- Select a model: Confirm the model's region.
- Select a URL: Choose the endpoint URL for the corresponding region. HTTP URLs are supported.
- Configure an API key: Select a region, get an API key, and configure the API key as an environment variable.
The sample code in this topic applies to the Singapore region.
HTTP
Video generation typically takes 1 to 5 minutes, so the API uses asynchronous invocation. The workflow has two steps: create a task, then poll for the result.
Step 1: Create a task and get the task ID
- 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 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)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be enable.Request bodymodelstring (Required)The model name. For a list of models and their prices, see Model pricing.Example: wan2.7-r2v, wan2.7-r2v-2026-06-12.input object (Required)The basic input information, such as the prompt.
Properties prompt string (Required)The text prompt describing the desired elements and visual features of the generated video.Supports Chinese and English. Each Chinese character, letter, and punctuation mark counts as one character. Text exceeding the limit is automatically truncated.
media array. Images and videos are counted separately, so "Image 1" and "Video 1" can coexist. If there is only one reference image or video, simplify the reference to "the reference image" or "the reference video".Scene description: For example, if reference Image 1 is a cat and Image 2 is a room. To describe the cat playing in the room, you can use two methods. One is to directly use the identifiers, such as "Image 1 is playing in Image 2". The other is to supplement the description with the subject and scene, such as "The cat from Image 1 is playing in the room from Image 2".When the reference image is a multi-panel storyboard, describe the scene in a multi-shot format in the prompt. You do not need to describe every panel — provide key shots, and the model automatically recognizes the panel logic and completes the remaining scenes. For best results, use only one multi-panel image at a time.For tips on using prompts, see Text-to-video/image-to-video prompt guide.negative_prompt string (Optional)A negative prompt describing content to exclude from the generated video. Use this to constrain the output.Supports Chinese and English. Maximum length: 500 characters. Text exceeding the limit is automatically truncated.Example: low resolution, error, worst quality, low quality, disfigured, extra fingers, bad proportions.media array (Required)An array of media assets (images, videos, and audio) used as visual and audio references. Images can include multiple views, commonly used for referencing characters, props, and scenes.
Properties type string (Required)The type of the media asset. Valid values:
string (Required)The URL of the media asset. Each value can point to one image or one video.
Pass a reference image (type=reference_image) The URL or Base64-encoded data of the reference image. The image can be a subject (person, animal, or object) or a background. When it includes a subject, it must contain only one character.Image limits:
Pass a reference video (type=reference_video) The URL of the reference video. The video should include a subject (person, animal, or object). Avoid using videos of backgrounds or empty scenes. When the video includes a subject, it must contain only one character. If the video has audio, the voice can also be referenced.Video limits:
string (Optional)The audio URL specifying the voice for the main character in the reference asset (image or video). Use this parameter with reference_image or reference_video. The audio serves only as a voice reference and does not determine spoken content. For best results, match the language of the reference audio to the language of the prompt.Audio logic:
object (Optional)The video processing parameters, such as the video resolution.
Properties resolution string (Optional)The resolution tier of the generated video. Controls the total pixel count.
string (Optional)The aspect ratio of the generated video.Behavior:
integer (Optional)The duration of the generated video in seconds.
boolean (Optional)Enables prompt rewriting. When enabled, a model rewrites the input prompt before generation. This significantly improves quality for shorter prompts but increases processing time.
boolean (Optional)Adds a watermark. The watermark text is "AI Generated", placed in the lower-right corner of the video.
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. |
You can pass multiple reference assets (images and videos) and specify a voice to generate a video. |
Response parametersoutputobjectThe output information of the task.
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.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. |
Save the task_id to query the task status and result. |
Step 2: Query the result by 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 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 parametersoutputobjectThe output information of the task.
Properties task_id string (Required)The ID of the task.task_status stringThe task status.
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.objectOutput statistics. Populated only for successful tasks.
Properties input_video_duration integerThe duration of the input video, in seconds.output_video_duration integerThe duration of the output video, in seconds.duration integerThe total video duration. Cost is calculated based on this value.Formula: duration = input_video_duration + output_video_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 generated videos. The value is 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 parameter names are largely consistent with the HTTP API. The parameter structure is encapsulated based on language features.
Reference-to-video tasks typically take 1 to 5 minutes. The SDK wraps the HTTP asynchronous flow and supports both synchronous and asynchronous calls.
Actual processing time depends on the queue length and service status.
Python SDK
Set base_http_api_url based on the model's region:
- Singapore
- Beijing
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'{WorkspaceId} with your actual workspace ID.
- Synchronous call
- Asynchronous call
A synchronous call blocks until video generation completes and returns the result directly.
Request example
Response example
The video_url is valid for 24 hours. Download the video promptly.
Java SDK
Set baseHttpApiUrl based on the model's region:
- Singapore
- Beijing
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";{WorkspaceId} with your actual workspace ID.
- Synchronous call
- Asynchronous call
A synchronous call blocks until video generation completes and returns the result directly.
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 resolution.
FAQ
How do I add a voice to a subject (voice reference)?
Only wan2.7 supports voice reference. In the media object, you can pass an audio URL in the reference_voice parameter to specify a reference voice for a reference image or video.