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 consists of two core steps: "create a task -> poll for the result", as follows:
Replace
Replace
The SDK parameter naming is basically the same as the HTTP API; the parameter structure is encapsulated according to language characteristics.
Reference-to-video tasks typically take 1-5 minutes. The SDK encapsulates the HTTP asynchronous call process and supports both synchronous and asynchronous call modes.
Set region according to the region where the model is located (passed in when constructing the Client; the region value differs across regions):
Replace
Set baseHttpApiUrl according to the region where the model is located:
Replace
If a model call fails and returns an error message, see Error codes to resolve the issue.
The main differences are as follows:
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 China (Beijing) region.
HTTP
Video generation typically takes 1 to 5 minutes, so the API uses asynchronous invocation. The workflow consists of two core steps: "create a task -> poll for the result", as follows:
Step 1: Create a task and get the task ID
- Beijing
- Singapore
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis{WorkspaceId} with your actual workspace ID.
- After the creation succeeds, use the
task_idreturned by the API to query the result. task_id is valid for 24 hours. Do not create duplicate tasks; polling is sufficient 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)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be set to 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.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, which is used to query the task status and result. |
Step 2: Query the result by task ID
- Beijing
- Singapore
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}{WorkspaceId} with your actual workspace ID.
- Polling recommendation: video generation takes a few minutes. It is recommended to use a polling mechanism and set a reasonable query interval (such as 15 seconds) to obtain the result.
- Task status flow: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- Result link: after the task succeeds, a video link is returned, valid for 24 hours. It is recommended to download it immediately after obtaining the link and transfer it to 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 as
UNKNOWN. - RPS limit: the query API has a default RPS of 20. If you need higher-frequency queries or event notifications, it is recommended to configure 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 parametersoutputobjectThe output information of the task.
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. The format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. The format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. The format is YYYY-MM-DD HH:mm:ss.SSS.video_urlstringVideo URL. Returned only when task_status is SUCCEEDED.The link is valid for 24 hours, and you can download the video from this URL. 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.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 integerTotal video duration. Billing is calculated based on the duration.Calculation formula: duration = input_video_duration + output_video_duration.SR integerThe resolution tier of the generated video. Example value: 720.ratio stringThe aspect ratio of the generated video. Example value: 16:9.video_count integerThe number of generated videos. Fixed at 1.stringUnique request identifier for tracing and troubleshooting. |
The video URL is retained for only 24 hours and is automatically cleared after it expires. Save the generated video in a timely manner. |
Call via DashScope SDK
The SDK parameter naming is basically the same as the HTTP API; the parameter structure is encapsulated according to language characteristics.
Reference-to-video tasks typically take 1-5 minutes. The SDK encapsulates the HTTP asynchronous call process and supports both synchronous and asynchronous call modes.
The actual time required depends on the number of queued tasks and the service running status.
Call via Python SDK
Set region according to the region where the model is located (passed in when constructing the Client; the region value differs across regions):
- Beijing
- Singapore
region="cn-beijing"{WorkspaceId} with your actual workspace ID.
- Synchronous call
- Asynchronous call
A synchronous call blocks until video generation is complete and returns the result directly.
Request example
Response example
The video_url is valid for 24 hours. Download the video promptly.
Java SDK invocation
Set baseHttpApiUrl according to the region where the model is located:
- Beijing
- Singapore
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";{WorkspaceId} with your actual workspace ID.
- Synchronous call
- Asynchronous call
A synchronous call blocks until video generation is complete and returns the result directly.
Request example
Response example
The video_url is valid for 24 hours. Download the video promptly.
Error codes
If a model call fails and returns an error message, see Error codes to resolve the issue.
FAQ
What code changes are required to upgrade from wan2.6 to wan2.7?
The main differences are as follows:
- Prompt reference syntax wan2.7 no longer uses identifiers such as character1 and character2. Instead, reference assets by type: use identifiers such as "Image 1" and "Image 2" for images, and "Video 1" and "Video 2" for videos. For details, see the prompt parameter.
-
Multi-shot control
- wan2.7: The shot_type parameter is not supported. Describe the storyboard in the prompt to achieve multi-shot effects.
- wan2.6: Set shot_type to multi to generate multi-shot videos.
-
Request parameter structure
- How reference assets are passed: wan2.7 uses
media(an array of objects, each containingtypeandurl), replacing the wan2.6reference_urls(an array of strings). - Resolution parameter: wan2.7 uses
resolution(such as720P), replacing the wan2.6size(such as1280*720). - audio parameter: wan2.7 generates videos with audio by default, and no configuration is required. wan2.6 requires you to explicitly set
audiototrueorfalse.
- How reference assets are passed: wan2.7 uses
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.