The Wan video character swap model replaces the main character in a video with a character from an image while preserving the original video's scene, lighting, and tone to ensure seamless integration.
Core feature: Replaces the main character in a video with a character from a specified image while preserving the original video’s actions, expressions, and environment.
Scenarios: This feature is suitable for use cases such as derivative content creation and film post-production.
Examples
The Wan wan2.2-animate-mix video character swap model supports two service modes: standard mode wan-std and professional mode wan-pro. These modes differ in performance and billing. For more information, see Billing and rate limiting.
Character image | Reference video | Output video (Standard mode | Output video (Professional mode |
|
HTTP
You must obtain an API key and set 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 generation is time-consuming. The HTTP API operates in asynchronous mode. The call process consists of two steps:
Create a task to get a task ID: Submit a request to create a task. The response includes a task_id.
Query the result by task ID: Use the task_id to poll the task status until the task completes and the video URL is returned.
Step 1: Create a task
Singapore region: POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis
Beijing region: 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 Postman.
Request parameters | Video character swapThe following example shows the request for the Singapore region. To use the model in the Beijing region, replace the base URL with: |
Request 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 parameter to | |
input The input parameter object, which contains the following fields: | |
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
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. We recommend that you 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 following example shows the request for the Singapore region. To use a model in the Beijing region, replace the base URL with: |
Request 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 Usage statistics for the task. Only successful results are counted. | |
request_id Unique identifier for the request. Use for tracing and troubleshooting issues. |
Limitations
Data retention: The task_id and video URL are retained for only 24 hours. After this period, they cannot be queried or downloaded. Promptly download the video to your local device.
Content moderation: Both input and output content are subject to content moderation. Requests containing non-compliant content return the error "IPInfringementSuspect" or "DataInspectionFailed". For more information, see Error messages.
Network access configuration: The video URL is stored in Object Storage Service (OSS). If your business system cannot access external OSS URLs due to security policies, add the following OSS domain names to the network access whitelist.
# OSS domain name list
dashscope-result-bj.oss-cn-beijing.aliyuncs.com
dashscope-result-hz.oss-cn-hangzhou.aliyuncs.com
dashscope-result-sh.oss-cn-shanghai.aliyuncs.com
dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com
dashscope-result-zjk.oss-cn-zhangjiakou.aliyuncs.com
dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com
dashscope-result-hy.oss-cn-heyuan.aliyuncs.com
dashscope-result-cd.oss-cn-chengdu.aliyuncs.com
dashscope-result-gz.oss-cn-guangzhou.aliyuncs.com
dashscope-result-wlcb-acdr-1.oss-cn-wulanchabu-acdr-1.aliyuncs.comBilling and rate limiting
For free quota and unit price, see Model pricing.
For rate limits, see Wan series.
Billing description:
Input is not billed. Output is billed. You are charged based on the duration in seconds of successfully generated videos.
If a model call fails or an error occurs during processing, no fees are charged, and your free quota is not consumed.
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 calling information is subject to an hourly delay. About one hour after a model is invoked, go to the Monitoring (Singapore or Beijing) page to view metrics such as the number of calls and the success rate. How to view model call records?
Q: How can I improve the quality of the generated video?
A: Follow these suggestions:
Ensure the character is framed similarly in the input image and the reference video.
Try to keep the body proportions of the character consistent between the image and the video.
Use high-definition source materials. Avoid blurry images and low-frame-rate videos to ensure accurate detail recognition.
Q: How do I convert a temporary video URL to a permanent one?
A: You cannot convert the URL directly. The correct procedure is for your backend service to retrieve the URL, download the video file programmatically, and then upload it to a permanent object storage service—such as OSS—to generate a new, permanent access URL.
Q: Can the returned video URL be played directly in a browser?
A: This is not recommended because the URL expires after 24 hours. The best practice is to have your backend download and store the video, then use the permanent URL for playback.
