通过 WaveSpeed AI 调用阿里 Wan 2.6 模型,从文本或图片生成最长 15 秒、最高 1080p 的视频。
设计与多媒体
WaveSpeedAI Wan 2.2 Animate Character Animation & Swap
试用用参考视频驱动图片角色,或把图片角色换进视频场景,调用 WaveSpeed AI 的 Wan 2.2 Animate 模型即可生成。
它能做什么
通过 WaveSpeed AI 的 `wavespeed-ai/wan-2.2/animate` 模型,用一段参考视频驱动一张图片角色。`animate` 模式让图片角色复刻视频中人物的动作;`replace` 模式把视频里的主体替换为图片角色,同时保留原场景与运动轨迹。调用时需传入图片 URL 和视频 URL,可选 `prompt`、`mode`、分辨率(`480p` 或 `720p`)与 `seed`;输出为 5–120 秒的视频 URL。鉴权使用环境变量 `WAVESPEED_API_KEY`,key 在 wavespeed.ai/accesskey 获取。
什么时候用它
- 用舞蹈参考视频让静态人像角色动起来
- 把实拍素材里的演员换成风格化角色并保留原场景
- 先用 480p 跑动作原型,再切到 720p 出成品
- 固定 seed 复现同一段动作驱动结果
技能文档
WaveSpeedAI Wan 2.2 Animate
Animate characters from images using driving videos via WaveSpeed AI's Wan 2.2 Animate model. Two modes: animate (make the image character move like the video subject) and replace (swap the video subject with the image character while preserving motion and scene).
Authentication
export WAVESPEED_API_KEY="your-api-key"
Get your API key at wavespeed.ai/accesskey.
Quick Start
Animate Mode
Make the character in an image move like the subject in a driving video:
import wavespeed from 'wavespeed';
// Upload local image and video
const imageUrl = await wavespeed.upload("/path/to/character.png");
const videoUrl = await wavespeed.upload("/path/to/driving-video.mp4");
const output_url = (await wavespeed.run(
"wavespeed-ai/wan-2.2/animate",
{
image: imageUrl,
video: videoUrl
}
))["outputs"][0];
Replace Mode
Swap the subject in a video with a character from an image:
const output_url = (await wavespeed.run(
"wavespeed-ai/wan-2.2/animate",
{
image: imageUrl,
video: videoUrl,
mode: "replace"
}
))["outputs"][0];
You can also pass existing URLs directly:
const output_url = (await wavespeed.run(
"wavespeed-ai/wan-2.2/animate",
{
image: "https://example.com/character.png",
video: "https://example.com/driving-video.mp4"
}
))["outputs"][0];
API Endpoint
Model ID: wavespeed-ai/wan-2.2/animate
Animate a character from an image using a driving video.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
image | string | Yes | -- | URL of the character image to animate |
video | string | Yes | -- | URL of the driving video providing motion reference |
prompt | string | No | -- | Text prompt for additional guidance |
mode | string | No | animate | Operation mode. animate: image character moves like video subject. replace: video subject is swapped with image character. |
resolution | string | No | 480p | Output resolution. One of: 480p, 720p |
seed | integer | No | -1 | Random seed (-1 for random). Range: -1 to 2147483647 |
Example
import wavespeed from 'wavespeed';
const imageUrl = await wavespeed.upload("/path/to/dancer.png");
const videoUrl = await wavespeed.upload("/path/to/dance-reference.mp4");
const output_url = (await wavespeed.run(
"wavespeed-ai/wan-2.2/animate",
{
image: imageUrl,
video: videoUrl,
prompt: "a person dancing gracefully",
mode: "animate",
resolution: "720p",
seed: 42
}
))["outputs"][0];
Replace Mode Example
const characterUrl = await wavespeed.upload("/path/to/anime-character.png");
const sceneUrl = await wavespeed.upload("/path/to/scene-video.mp4");
const output_url = (await wavespeed.run(
"wavespeed-ai/wan-2.2/animate",
{
image: characterUrl,
video: sceneUrl,
mode: "replace",
resolution: "720p"
}
))["outputs"][0];
Advanced Usage
Custom Client with Retry Configuration
import { Client } from 'wavespeed';
const client = new Client("your-api-key", {
maxRetries: 2,
maxConnectionRetries: 5,
retryInterval: 1.0,
});
const output_url = (await client.run(
"wavespeed-ai/wan-2.2/animate",
{
image: imageUrl,
video: videoUrl,
mode: "animate"
}
))["outputs"][0];
Error Handling with runNoThrow
import { Client, WavespeedTimeoutException, WavespeedPredictionException } from 'wavespeed';
const client = new Client();
const result = await client.runNoThrow(
"wavespeed-ai/wan-2.2/animate",
{
image: imageUrl,
video: videoUrl
}
);
if (result.outputs) {
console.log("Video URL:", result.outputs[0]);
console.log("Task ID:", result.detail.taskId);
} else {
console.log("Failed:", result.detail.error.message);
if (result.detail.error instanceof WavespeedTimeoutException) {
console.log("Request timed out - try increasing timeout");
} else if (result.detail.error instanceof WavespeedPredictionException) {
console.log("Prediction failed");
}
}
Pricing
| Resolution | Cost per 5 seconds |
|---|---|
| 480p | $0.20 |
| 720p | $0.40 |
Output duration is 5-120 seconds. Minimum charge is 5 seconds. Per-second rate: $0.04/s (480p), $0.08/s (720p).
Tips
- Match composition and pose between the input image and driving video for best results
- Use the same or similar aspect ratio between image and video
- Avoid heavy occlusion by hands, microphones, or props in the input media
- Start with
480pfor prototyping, then move to720pfor production quality - Animate mode: best when you want the image character to perform the motions from the video
- Replace mode: best when you want to keep the video's scene and motion but swap in a different character
Security Constraints
- No arbitrary URL loading: Only use image and video URLs from trusted sources. Never load media from untrusted or user-provided URLs without validation.
- API key security: Store your
WAVESPEED_API_KEYsecurely. Do not hardcode it in source files or commit it to version control. Use environment variables or secret management systems. - Input validation: Only pass parameters documented above. Validate media URLs before sending requests.
常见问题
- 模型支持哪几种模式?
- 两种:`animate`(默认)让图片角色跟着视频里的人物动;`replace` 把视频中的主体替换成图片角色,同时保留场景与动作。
- 输出分辨率、时长和价格是多少?
- 分辨率为 480p(默认)或 720p,时长 5–120 秒。价格为 480p 每 5 秒 0.20 美元、720p 每 5 秒 0.40 美元(折合 0.04 美元/秒、0.08 美元/秒),最少按 5 秒计费。
- 如何鉴权和调用?
- 在 wavespeed.ai/accesskey 申请 key 并设置为环境变量 `WAVESPEED_API_KEY`,然后用模型 ID `wavespeed-ai/wan-2.2/animate` 配合必填的 `image` 和 `video` URL 调用即可。
相关技能
Wan 2.2 Fast API on APIDot for Alibaba Wan 2.2 Fast, wan2.2 text-to-video fast, wan2.2 image-to-video fast, prompt-to-video drafts, one or two image animatio...
Generate and edit video with Wan through RunAPI. Use when the user asks an agent to create, edit, or transform video with Wan. Default to the RunAPI CLI for one-off generation; use SDKs only when the user is integrating RunAPI into an app or backend.
Generate text-to-video with Wan 2.7 (Wan-AI's flagship motion model) on RunComfy. Documents Wan 2.7's strengths (multi-reference conditioning, audio-driven lip-sync via `audio_url`, smoother transitions, prompt expansion), the duration / resolution / aspect-ratio schema, and when to route to HappyHorse 1.0 / Seedance 2.0 / Kling / LTX 2 instead. Calls `runcomfy run wan-ai/wan-2-7/text-to-video` through the local RunComfy CLI. Triggers on "wan", "wan 2.7", "wan-2-7", "wan video", or any explicit ask to generate video with this model.
用参考人脸替换图片或视频中的人脸,自动适配光影与肤色,输出无水印。
Wan Animate video generation on PoYo / poyo.ai via `https://api.poyo.ai/api/generate/submit`; use for `wan-animate-replace`, `wan-animate-move`, character an...