Wan 2.7 API
阿里巴巴 Wan 2.7 影片生成模型的完整 API 參考文件。
模型變體
此 API 支援四種模型變體:
快速對比
Wan 2.7 文字生成影片
API 位址
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 僅用於引導聲音特徵,所需的說話內容請在提示詞中描述