The Wan video character swap model replaces the main character in a video with a character from an image. This model preserves the scene, lighting, and tone of the original video to ensure a seamless result.
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 scenarios that require character replacement, such as derivative works and film post-production.
Examples
The wan2.2-animate-mix video character swap model provides 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 cause authentication failures or service errors.
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
Video generation is time-consuming. The HTTP API uses asynchronous mode. The call process has two steps:
Create a task to obtain a task ID: Submit a request to create a task. The request returns a task_id.
Query the result by task ID: Use the task_id to poll the task status until the task is complete and you obtain the video URL.
Step 1: Create a task and get the task ID
After the task is created, use the returned
task_idto query the result. The task_id is valid for 24 hours. Do not create duplicate tasks. Use polling to retrieve the result.
Request parameters | Video character swapThe following example shows the request for the Singapore region. To use a model in the Beijing region, replace the base URL with: |
Request headers | |
Content-Type The content type of the request. Set this parameter to | |
Authorization The identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx. | |
X-DashScope-Async The asynchronous processing configuration parameter. HTTP requests support only asynchronous processing. You must set this parameter to Important If this request header is missing, the error message "current user api does not support synchronous calls" is returned. | |
Request body | |
model The model name. Must be set to | |
input The input parameter object, which contains the following fields: | |
parameters |
Response parameters | Successful responseSave the task_id to query the task status and result. Error responseThe task creation failed. For more information, see Error messages to resolve the issue. |
output Task output information. | |
request_id The unique request ID. You can use this ID to trace and troubleshoot issues. | |
message The detailed information about a failed request. This parameter is not returned if the request is successful. For more information, see Error messages. | |
code The error code for a failed request. This parameter is not returned if the request is successful. For more information, see Error messages. |
Step 2: Query the result by task ID
Singapore region: GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id}
Beijing region: GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
Polling suggestion: Video generation takes several minutes. Use a polling mechanism and set a reasonable query interval, such as 15 seconds, to retrieve the result.
Task status transition: PENDING → RUNNING → SUCCEEDED or FAILED.
Result link: After the task is successful, a video link is returned. The link is valid for 24 hours. After you retrieve the link, immediately download and save the video to a permanent storage service, such as Object Storage Service.
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 identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx. | |
URL path parameters | |
task_id The task ID. |
Response parameters | Task succeededVideo URLs are retained for only 24 hours and are automatically purged after this period. You must save the generated videos promptly. Task failedIf a task fails, task_status is set to FAILED, and an error code and message are provided. For more information, see Error messages to resolve the issue. |
output Task output information. | |
usage Usage statistics for the task. Only successful results are counted. | |
request_id The unique request ID. You can use this ID to trace and troubleshoot 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 with non-compliant content return the error "IPInfringementSuspect" or "DataInspectionFailed". For more information, see Error messages.
Network access configuration: The video URL is stored in Alibaba Cloud 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
The wan2.2-animate-mix model provides two service modes, standard mode wan-std and professional mode wan-pro, to support video character replacement effects in different scenarios.
International (Singapore)
Model | Service | Description | Rate limits (shared by Alibaba Cloud account and RAM users) | Unit price | Free quota (View) | |
RPS limit for task submission API | Number of concurrent tasks | |||||
wan2.2-animate-mix | Standard mode | Fast generation speed. Cost-effective for basic needs such as simple animation demos. | 5 | 1 | $0.18/second | 50 seconds shared by both services |
Professional mode | High animation smoothness and natural transitions for actions and expressions. The effect is closer to a real video. | $0.26/second | ||||
Mainland China (Beijing)
Model | Service | Description | Rate limits (shared by Alibaba Cloud account and RAM users) | Unit price | Free quota (View) | |
RPS limit for task submission API | Number of concurrent tasks | |||||
wan2.2-animate-mix | Standard mode | Fast generation speed. Cost-effective for basic needs such as simple animation demos. | 5 | 1 | $0.09/second | No free quota |
Professional mode | High animation smoothness and natural transitions for actions and expressions. The effect is closer to a real video. | $0.13/second | ||||
Billing rules
Billing mode: This service is billed on a pay-as-you-go basis. You are charged based on the duration (in seconds) of successfully generated videos. The billable duration is determined by the
usage.video_durationfield in the successful task response.Consumption order: The free quota is consumed first. After the free quota is used up, the pay-as-you-go billing method is used by default. You can enable the "Free quota only" feature to avoid extra charges after your free quota is used up. For more information, see Free quota for new users.
No charge for failed calls: If a model call fails or an error occurs during processing, no fees are charged, and your free quota is not consumed.
Rate limiting: An Alibaba Cloud account and its RAM users share a total request frequency limit of 5 requests per second. A maximum of 1 task can be processed at a time. New tasks that exceed the limit are added to a queue. For more information about model throttling rules and FAQ, see Rate limits.
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 Model Observation (Singapore or Beijing) page to view metrics such as the number of calls and the success rate. How do I 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 using code, and then upload it to a permanent object storage service, such as Alibaba Cloud 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.
