Replaces the main character in a video with a character from an image while preserving the original scene, lighting, and tone for seamless integration.
-
Core features: Replaces the character in a video with a person from a specified image while preserving the actions, expressions, and environment of the original video.
-
Scenarios: Ideal for character replacement scenarios like derivative content creation and post-production.
Examples
wan2.2-animate-mix offers two service modes: standard mode (wan-std) and professional mode (wan-pro). See Billing and rate limiting for performance and billing differences.
|
Character image |
Reference video |
Output video (standard mode |
Output video (professional mode |
|
|
HTTP
Get an API key and export the API key as an environment variable.
The Beijing and Singapore regions have separate API keys and request endpoints. Do not use them interchangeably. Cross-region calls result in authentication failures or service errors.
Video character swap tasks are time-consuming, so the API uses asynchronous invocation with two steps: create a task, then poll for the result.
Step 1: Create a task
Singapore: POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis
Beijing: POST https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/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 a beginner's tutorial, see Use Postman or cURL.
Request parameters |
Video character swapThe following is the base_url for the Singapore region. If you use a model from the Beijing region, replace the base_url with:
|
Headers |
|
|
Content-Type The content type of the request. Must be |
|
|
Authorization The authentication credentials using a Model Studio API key. Example: |
|
|
X-DashScope-Async Enables asynchronous processing. Must be Important Returns "current user api does not support synchronous calls" error if not included. |
|
Request body |
|
|
model The model name. Set this to |
|
|
input Basic input information. |
|
|
parameters |
Response parameters |
Successful responseSave the Error responseTask creation failed. See error codes to resolve the issue. |
|
output Task output information. |
|
|
request_id Unique identifier for the request. Use for tracing and troubleshooting issues. |
|
|
message Detailed error message. Returned only when the request fails. See error codes for details. |
|
|
code The error code. Returned only when the request fails. See error codes for details. |
Step 2: Query the result by task ID
Singapore: GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id}
Beijing: GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
Polling suggestion: Video generation can take several minutes. Use a polling mechanism with a reasonable query interval, such as 15 seconds, to retrieve the result.
Task status transition: PENDING → RUNNING → SUCCEEDED or FAILED.
Result URL: After the task is successful, a video URL is returned. The URL is valid for 24 hours. After you retrieve the URL, you must immediately download and save the video to a permanent storage service, such as Object Storage Service (OSS).
task_id validity: 24 hours. After this period, you cannot query the result, and the API returns a task status of
UNKNOWN.
Request parameters |
Query task resultReplace The base URL below is for the Singapore region. If you use a model in the Beijing region, replace the base URL with:
|
Headers |
|
|
Authorization The authentication credentials using a Model Studio API key. Example: |
|
URL path parameters |
|
|
task_id The ID of the task to query. |
Response parameters |
Task succeededVideo URLs are retained for only 24 hours and then automatically purged. Save generated videos promptly. Task failedWhen a task fails,
|
|
output Task output information. |
|
|
usage Statistics for successful tasks only. |
|
|
request_id Unique identifier for the request. Use for tracing and troubleshooting issues. |
Limitations
Data retention: Task ID and video URL are retained for 24 hours only. Download the video to your local device before expiration.
Content moderation: Input and output content are subject to moderation. Prohibited content returns `IPInfringementSuspect` or `DataInspectionFailed` errors. For more information, see Error messages.
Billing and rate limiting
-
For free quota and unit price, see model pricing.
-
For rate limits, see Wan series.
-
Billing details:
-
Billing is based on output video duration (in seconds) for successfully generated videos only. Input is not billed.
-
Failed calls and processing errors do not incur fees or consume free quota.
-
Error codes
If a model call fails and an error message is returned, see Error messages to resolve the issue.
FAQ
Q: How do I view model call usage?
A: Model invocation data has approximately 1-hour delay. View metrics (invocation volume, count, success rate) on the Monitoring (Singapore or Beijing) page after invocation. For more information, see How do I view model invocation records?
Q: How can I optimize the quality of generated videos?
A: To optimize quality:
-
Ensure consistent character framing between input image and reference video.
-
Maintain consistent body proportions between image and video.
-
Use high-definition source material. Avoid blurry images or low-frame-rate videos for accurate detail recognition.
Q: How do I convert a temporary video link to a permanent link?
A: You cannot convert the link directly. Have your backend service download the video file and upload it to Object Storage Service (OSS) to generate a permanent access link.
Q: Can the returned video link be played directly in a browser?
A: Not recommended -- links expire after 24 hours. Best practice: download and store the video on your backend, then use a permanent link for playback.
Q: How do I get the domain name whitelist for video storage?
A: Videos generated by models are stored in OSS. The API returns a temporary public URL. To configure a firewall whitelist for this download URL, note the following: The underlying storage may change dynamically. This topic does not provide a fixed OSS domain name whitelist to prevent access issues caused by outdated information. If you have security control requirements, contact your account manager to obtain the latest OSS domain name list.
