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 in derivative content creation and post-production.
Examples
wan2.2-animate-mix supports 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 modewan-std) | Output video (professional modewan-pro) |
|---|---|---|---|
![]() |
HTTP
Obtain an API key and export the API key as an environment variable.
Character swap is time-consuming, so the API uses asynchronous invocation: create a task, then poll for the result.
Step 1: Create a task
Singapore:POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis
Beijing:POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis
Replace {WorkspaceId} with your actual workspace ID.
- 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 guidance for beginners, see Call APIs with Postman or cURL.
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 enable.Request bodymodelstring (Required)The model name. Set this to wan2.2-animate-mix.input object (Required)Input images and video for the character swap.
Properties image_url string (Required)A publicly accessible HTTP or HTTPS URL for the character image. The URL must not contain non-ASCII characters (e.g., Chinese). If it does, encode the URL before passing it.
string (Required)A publicly accessible HTTP or HTTPS URL for the reference video. The URL must not contain non-ASCII characters (e.g., Chinese). If it does, encode the URL before passing it.Tip: Higher resolution and frame rate improve output quality.
boolean (Optional)Adds an "AI Generated" watermark in the lower-right corner of the output video.
object (Required)
Properties check_image boolean (Optional)Controls whether the input image is checked before processing.
string (Required)The service mode. Two modes are available:
|
The following is the Singapore region URL. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region. |
Response parametersoutputobjectTask output information.
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.message stringDetailed error message. Returned only for failed requests. See Error codes.code stringError code. Returned only for failed requests. See Error codes. |
Save the task_id to query the task status and result. |
Step 2: Query the result by task ID
- Singapore
- China (Beijing)
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}When calling, replace {WorkspaceId} with your actual workspace ID.- Polling recommendation: Video generation takes several minutes. Use a polling mechanism with a reasonable interval, such as 15 seconds.
- Task state transition: PENDING → RUNNING → SUCCEEDED or FAILED.
- Result link: After a task succeeds, a video URL valid for 24 hours is returned. Download and save the video to permanent storage, such as OSS.
task_idvalidity: 24 hours. After this period, queries return the task status asUNKNOWN.
Request parametersHeadersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.URL path parameterstask_idstring (Required)The ID of the task. |
Replace 0385dc79-5ff8-4d82-bcb6-xxxxxx with your actual task_id.The following is the Singapore region URL. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region. |
Response parametersoutputobjectTask output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.results object
Properties video_url stringURL of the generated video. Returned only when task_status is SUCCEEDED.Valid for 24 hours. The video is in MP4 format with H.264 encoding.stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes.objectReturned for successful tasks only.
Properties video_duration floatDuration of the generated video, in seconds.video_ratio stringThe service mode used for this request. Returns standard for wan-std mode, or pro for wan-pro mode.stringUnique request identifier for tracing and troubleshooting. |
Video URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. |
Limitations
Data retention: Task IDs and video URLs are retained for 24 hours. Download the video to your local device before they expire.
Content moderation: All input and output content is subject to moderation. Prohibited content returns IPInfringementSuspect or DataInspectionFailed errors. For details, see Error codes.
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 the 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 call fails, see Error codes.
FAQ
Q: How do I view model call usage?
A: Invocation data has approximately a 1-hour delay. View metrics (invocation volume, count, and success rate) on the Monitoring (Singapore or Beijing) page. For more information, see How do I view model invocation records?
Q: How can I improve the quality of generated videos?
A: To get better results:
- Frame the character consistently in both the input image and the reference video.
- Keep body proportions consistent between the image and the video.
- Use high-definition source material — blurry images or low-frame-rate videos reduce detail accuracy.
Q: How do I convert a temporary video link to a permanent link?
A: Direct conversion is not supported. Have your backend download the video and upload it to Object Storage Service (OSS) to get a permanent access link.
Sample code: Download a video to a local device
Sample code: Download a video to a local device
