Wan 2.7 API
阿里巴巴 Wan 2.7 视频生成模型的完整 API 参考文档。
模型变体
此 API 支持四种模型变体:
快速对比
Wan 2.7 文本生成视频
接口地址
POST /api/v1/video/task
请求参数
必填参数
可选参数
请求示例
const response = await fetch('https://api.flaq.ai/api/v1/video/task', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_name: 'wan-2.7-text-to-video',
prompt: 'A cat playing with a ball of yarn in a sunlit room',
duration: 6,
resolution: '720p',
aspect_ratio: '16:9',
negative_prompt: 'blur, low quality',
seed: 42
})
});
const { data } = await response.json();
const taskId = data.task_id;
Wan 2.7 图像生成视频
请求参数
必填参数
可选参数
请求示例
{
model_name: 'wan-2.7-image-to-video',
image_url: 'https://example.com/first-frame.jpg',
image_end_url: 'https://example.com/last-frame.jpg',
video_url: 'https://example.com/reference-continuation.mp4',
audio_url: 'https://example.com/driving-audio.mp3',
prompt: 'Gentle camera push-in; leaves rustle softly in the breeze',
duration: 6,
resolution: '720p',
negative_prompt: 'blur, low quality',
seed: 42
}
Wan 2.7 视频编辑
请求参数
必填参数
可选参数
请求示例
{
model_name: 'wan-2.7-video-edit',
prompt: 'Replace the sky with warm sunset colors, keep subjects natural',
negative_prompt: 'artifacts, flicker',
seed: 42,
video_url: 'https://example.com/source.mp4',
images: ['https://example.com/ref-a.jpg', 'https://example.com/ref-b.jpg'],
audio_setting: 'auto'
}
Wan 2.7 参考视频生成
根据按顺序排列的图像和视频参考生成新视频,并可选择使用一个音频片段提供声音指导。
请求参数
必填参数
参考媒体
至少需要一张参考图像或一个参考视频。images 和 videos 合计不得超过 5 个项目。
可选参数
@ (AT) 引用占位符
@ (AT) 引用功能通过带编号的 <<<...>>> 占位符将参考媒体关联到提示词。每种媒体类型的编号均独立从 1 开始,并遵循对应数组的顺序。
请求示例
{
model_name: 'wan-2.7-reference-to-video',
prompt: 'Use image one for the hero and video one for the motion; keep the hero voice consistent with audio one',
resolution: '1080p',
duration: 8,
aspect_ratio: '16:9',
images: ['https://example.com/hero-reference.jpg'],
videos: ['https://example.com/motion-reference.mp4'],
audios: ['https://example.com/voice-reference.mp3'],
negative_prompt: 'flicker, distorted hands, duplicate subjects',
seed: 42
}
@ (AT) 参考视频生成请求示例
{
model_name: 'wan-2.7-reference-to-video',
prompt: 'Place the presenter from <<<image_1>>> in the studio from <<<image_2>>>, follow the camera path in <<<video_1>>>, and use the reference voice from <<<audio_1>>>',
resolution: '1080p',
duration: 8,
aspect_ratio: '16:9',
images: [
'https://example.com/presenter-reference.jpg',
'https://example.com/studio-reference.jpg'
],
videos: ['https://example.com/camera-path-reference.mp4'],
audios: ['https://example.com/voice-reference.mp3'],
negative_prompt: 'flicker, distorted hands, duplicate subjects',
seed: 42
}
响应格式
初始响应
所有模型均返回用于轮询的 task_id:
{
"code": 0,
"message": "success",
"data": {
"task_id": "{task_id}",
"response_url": "https://api.flaq.ai/api/v1/video/{task_id}",
"task_status": "submitted"
}
}
轮询响应
通过 GET /api/v1/video/{taskId} 查询任务状态:
{
"code": 0,
"message": "success",
"data": {
"task_id": "{task_id}",
"response_url": "https://api.flaq.ai/api/v1/video/{task_id}",
"task_status": "succeed",
"task_status_msg": null,
"task_result": {
"videos": [
{
"url": "https://example.com/generated-video.mp4"
}
]
}
}
}
状态值说明
submitted:任务已提交,等待处理
processing:视频生成中
succeed:视频生成完成
failed:视频生成失败
处理时间
典型处理时间为 2-5 分钟,具体取决于时长和分辨率设置。
1080p 下较长视频(10-15 秒)最多可能需要 8 分钟。
最佳实践
- 描述场景与运动:提示词中同时包含场景内容和镜头运动描述
- 分辨率选择:720p 处理速度更快,1080p 画质最佳
- 时长规划:视频越长费用越高(按秒计费)
- 音频集成:通过
audio_url 参数添加自定义音频
- 图像质量:图像生成视频时,使用高质量输入图像以获得最佳效果
- 视频编辑提示词:明确说明需要修改的内容和需要保留的内容
- 参考素材数量:Reference-to-Video 的
images 与 videos 合计应保持在 5 个以内
- 参考声音:
audios 仅用于指导声音特征,所需的说话内容请在提示词中描述