The Wan reference-to-video model supports multimodal input (images, videos, and audio) and generates videos that maintain consistent character appearance and voice, making it suitable for single-character performance or multi-character interaction scenarios.
Related documents: 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 video generation tasks take a long time (usually 1 to 5 minutes), the API uses asynchronous calls. The entire process involves two core steps: "create a task -> poll for the result", as follows:
When you call the API, replace
When you call the API, replace
The SDK parameter naming is basically the same as that of the HTTP API, and the parameter structure is encapsulated based on language-specific features.
A reference-to-video task usually takes 1–5 minutes. The SDK encapsulates the HTTP asynchronous call process and supports both synchronous and asynchronous call methods.
Set region based on the region where the model is located (pass it in when constructing the Client; the region value varies by region):
When you call the API, replace
Set baseHttpApiUrl based on the region where the model is located:
When you call the API, 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 this. Pass an audio URL via
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 are supported.
- Configure the API Key: Select the region and obtain and configure an API Key, then configure the API Key as an environment variable.
The sample code in this topic applies to the Singapore region.
HTTP call
Since video generation tasks take a long time (usually 1 to 5 minutes), the API uses asynchronous calls. The entire process involves two core steps: "create a task -> poll for the result", as follows:
Step 1: Create a task to obtain 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 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; just poll for the result. - For a quick start guide, see Postman.
Request parametersRequest headersContent-Typestring(required)Request content type. This parameter must be set to application/json.Authorizationstring(required)Request authentication. The API uses the 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 mode only and must be set to enable.Request Bodymodelstring (Required)The model name. For the model list and prices, see Model Price.Example values: wan2.7-r2v, wan2.7-r2v-2026-06-12.input object (Required)Basic input information, such as the prompt.
Properties prompt string (Required)The text prompt. It describes the elements and visual characteristics you want in the generated video.Supports Chinese and English. Each Chinese character, letter, and punctuation mark counts as one character, and the excess is automatically truncated.
media array order. Images and videos are counted separately, so labels such as Image 1 and Video 1 can coexist. If there is exactly one image or one video as the reference, you can simply write "reference image" or "reference video".Scene description: Suppose reference Image 1 is a cat and Image 2 is a room. To describe the cat playing in the room, two styles are supported: one directly uses the labels (for example, "Image 1 plays in Image 2"); the other adds the subject and scene for clarification (for example, "the cat in Image 1 plays in the room in Image 2").When a reference image is a multi-grid (storyboard) image, describe the content in a multi-shot form in the prompt. You do not need to describe every grid; providing the key shots is enough — the model automatically recognizes the grid logic and intelligently completes the shot content. For better results, it is recommended to input only one multi-grid image at a time.For prompt tips, see the T2V/I2V Prompt Guide.negative_prompt string (Optional)The negative prompt, used to describe content that you do not want to appear in the video, which constrains the video output.Supports Chinese and English, up to 500 characters in length; the excess is automatically truncated.Example values: low resolution, fault, worst quality, low quality, deformed, extra fingers, bad proportions, etc.media array (Required)The media assets array, which includes images, videos, and audio. Images/videos are supported as visual references; images support multi-view. Common references include characters, props, and scenes.
Properties type string (Required)The media asset type. Valid values:
string (required)Media asset URL. Each value can point to an image or a video.
Input a reference image (type=reference_image) The reference image URL or Base64-encoded data. The reference image can be a subject (person/animal/object) or a background. When a subject is included, include only one character.Image limits:
Input a reference video (type=reference_video) The reference video URL. The video content is recommended to contain a subject (person/animal/object); background or empty-scene videos are not recommended. When a subject is included, include only one character. If the video has sound, the voice can also be used as a reference.Video limits:
string (optional)The audio URL. It is used to specify the voice of the main character in the reference asset (image/video). Use it together with reference_image or reference_video. This audio serves only as a voice reference and is independent of the spoken content. For better matching, keep the language of the reference audio consistent with that of the prompt.Audio activation logic:
object (optional)Video processing parameters, such as setting the video resolution.
Properties resolution string (optional)The resolution tier of the generated video, used to control video clarity (total pixels).
string (optional)The aspect ratio of the generated video.Effective logic:
integer (optional)The duration of the generated video, in seconds.
boolean (optional)Whether to enable intelligent prompt rewriting. When enabled, a large language model is used to intelligently rewrite the input prompt. This significantly improves the generation results for short prompts, but increases processing time.
boolean (optional)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, ranging from [0, 2147483647].If not specified, the system automatically generates a random seed. To improve the reproducibility of generation results, we recommend fixing the seed value.Note that due to the probabilistic nature of model generation, even with the same seed, the generation results are not guaranteed to be exactly identical each time. |
Provide multiple reference assets (images + videos) and specify a voice to generate a video. |
Response parametersoutputobjectThe task output information.
Properties task_id stringThe task ID. Query validity: 24 hours.task_status stringThe task status.
Enumerated values
stringThe unique request identifier. It can be used to trace request details and troubleshoot issues.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. |
Save the task_id, which is used to query the task status and results. |
Step 2: Query results 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. We recommend using a polling mechanism and setting a reasonable query interval (such as 15 seconds) to obtain results.
- Task status transitions: PENDING (queuing) → RUNNING (processing) → SUCCEEDED (success) / FAILED (failed).
- Result link: A video link is returned after the task succeeds, with a validity period of 24 hours. We recommend downloading the video immediately after obtaining the link and transferring it to permanent storage (such as Alibaba Cloud OSS).
- task_id validity period: 24 hours. After it expires, results can no longer be queried, and the API returns the task status
UNKNOWN.
Request parametersRequest headers (Headers)Authorizationstring(required)Request authentication. The API uses the Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.URL path parameters (Path parameters)task_idstring(Required)The task ID. |
Replace {task_id} entirely with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours. Also replace {WorkspaceId} with your actual workspace ID. |
Response parametersoutputobjectThe task output information.
Properties task_id string(Required)The task ID.task_status stringThe task status.
Enumerated values
stringThe task submission time. The time zone is UTC+8, in the format YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe task execution time. The time zone is UTC+8, in the format YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe task 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 via this URL. The video format is MP4 (H.264 encoding).orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.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.objectOutput information statistics. Only successful results are counted.
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. Billing is calculated based on the duration.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.stringThe unique request identifier. It can be used to trace request details and troubleshoot issues. |
The video URL is retained for only 24 hours and will be automatically deleted after it expires. Save the generated video in a timely manner. |
Calling the DashScope SDK
The SDK parameter naming is basically the same as that of the HTTP API, and the parameter structure is encapsulated based on language-specific features.
A reference-to-video task usually takes 1–5 minutes. The SDK encapsulates the HTTP asynchronous call process and supports both synchronous and asynchronous call methods.
The actual time required depends on the number of queued tasks and the service running status.
Calling the Python SDK
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
region="ap-southeast-1"{WorkspaceId} with your actual workspace ID.
- Synchronous call
- Asynchronous call
A synchronous call blocks until video generation is complete and directly returns the result.
Request example
Response example
The video_url is valid for 24 hours. Download the video in a timely manner.
Calling the Java SDK
Set baseHttpApiUrl based on the region where the model is located:
- 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 is complete and directly returns the result.
Request example
Response example
The video_url is valid for 24 hours. Download the video in a timely manner.
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 when upgrading from wan2.6 to wan2.7?
The main differences are as follows:
- Different reference notation in prompts wan2.7 no longer uses identifiers such as character1 and character2. Instead, references are made by type: images are referenced as "Image 1", "Image 2", and videos as "Video 1", "Video 2". For details about prompts, see prompt parameter.
-
Different multi-shot control method
- wan2.7: The shot_type parameter is not supported. Multi-shot effects are achieved by describing the storyboard in the prompt.
- wan2.6: Multi-shot videos are generated by setting shot_type to multi.
-
Different request parameter structure
- How reference assets are passed in: wan2.7 uses
media(an array of objects, each containingtypeandurl), replacing wan2.6'sreference_urls(an array of strings). - Resolution parameter: wan2.7 uses
resolution(for example,720P), replacing wan2.6'ssize(for example,1280*720). - audio parameter: wan2.7 generates videos with audio by default, so no setting is required. wan2.6 requires explicitly setting
audiototrueorfalse.
- How reference assets are passed in: wan2.7 uses
How do I add a voiceover for a subject (voice reference)?
Only wan2.7 supports this. Pass an audio URL via reference_voice in media to specify a reference voice for a reference image or reference video.