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.
Model Studio has released a workspace-specific domain for the Singapore region: https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com. The new dedicated domain delivers superior performance and higher stability for inference requests. We recommend migrating from https://dashscope-intl.aliyuncs.com to the new domain.
{WorkspaceId} is your workspace ID, which can be found on the Workspace Details page in the Model Studio console. The existing domain remains fully functional.
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 mode |
Output video (professional mode |
|
|
HTTP
Obtain an API key and export the API key as an environment variable.
The China (Beijing) and Singapore regions have separate API keys and request endpoints. They cannot be used interchangeably. Cross-region calls lead to authentication failures or service errors.
Character swap is time-consuming, so the API uses asynchronous invocation: create a task, then poll for the result.
Step 1: Create a task
Beijing: POST https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis
Singapore: POST https://{WorkspaceId}.ap-southeast-1.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 parameters |
Video character swapThe following is the China (Beijing) region URL. URLs vary by region.
|
Headers |
|
|
Content-Type The content type of the request. Must be |
|
|
Authorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. |
|
|
X-DashScope-Async Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be Important
If this request header is missing, the error "current user api does not support synchronous calls" is returned. |
|
Request body |
|
|
model The model name. Set this to |
|
|
input Input images and video for the character swap. |
|
|
parameters |
Response parameters |
Successful responseSave the
Error responseTask creation failed. See Error codes.
|
|
output Task output information. |
|
|
request_id Unique request identifier for tracing and troubleshooting. |
|
|
message Detailed error message. Returned only for failed requests. See Error codes. |
|
|
code Error code. Returned only for failed requests. See Error codes. |
Step 2: Query the result by task ID
China (Beijing)
GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
Singapore
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. -
RPS limit: The default RPS for the query API is 20. For higher-frequency queries or event notifications, we recommend that you configure an asynchronous task callback.
-
More operations: For batch queries, task cancellation, and other operations, see Manage asynchronous tasks.
Request parameters |
Query task resultReplace The following is the China (Beijing) region URL. URLs vary by region.
|
Headers |
|
|
Authorization Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. |
|
URL path parameters |
|
|
task_id The ID of the task. |
Response parameters |
Task succeededVideo URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. Task failedWhen a task fails,
|
|
output Task output information. |
|
|
usage Returned for successful tasks only. |
|
|
request_id Unique request identifier for tracing and troubleshooting. |
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 (Beijing or Singapore) 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.
Q: Can the returned video link be played directly in a browser?
A: This is not recommended — links expire after 24 hours. Download and store the video on your backend, then serve it via a permanent link.
Q: How do I get the domain name allowlist 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.
