Wan 2.7 API
เอกสารอ้างอิง API ฉบับสมบูรณ์สำหรับโมเดลสร้างวิดีโอ Wan 2.7 โดย Alibaba.
ตัวเลือกโมเดล {#}
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
}
ตัวอย่างคำขอ Reference-to-Video แบบ @ (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 สำหรับ Poll:
{
"code": 0,
"message": "success",
"data": {
"task_id": "{task_id}",
"response_url": "https://api.flaq.ai/api/v1/video/{task_id}",
"task_status": "submitted"
}
}
การตอบกลับจากการ Poll
Poll 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 นาที ขึ้นอยู่กับระยะเวลาและการตั้งค่าความละเอียด.
วิดีโอที่ยาวขึ้น (10-15 วินาที) ที่ 1080p อาจใช้เวลาสูงสุด 8 นาที.
แนวทางปฏิบัติที่ดี
- อธิบายฉากและการเคลื่อนไหว: ใส่ทั้งเนื้อหาฉากและการเคลื่อนไหวของกล้องในพรอมต์
- การเลือกความละเอียด: ใช้ 720p เพื่อประมวลผลเร็วขึ้น และ 1080p เพื่อคุณภาพสูงสุด
- การวางแผนระยะเวลา: วิดีโอที่ยาวขึ้นมีค่าใช้จ่ายสูงขึ้น (คิดราคาต่อวินาที)
- การผสานเสียง: เพิ่มเสียงแบบกำหนดเองผ่านพารามิเตอร์
audio_url
- คุณภาพรูปภาพ: สำหรับ image-to-video ให้ใช้รูปภาพอินพุตคุณภาพสูงเพื่อผลลัพธ์ที่ดีที่สุด
- พรอมต์แก้ไขวิดีโอ: ระบุให้ชัดเจนว่าต้องการเปลี่ยนอะไรและคงอะไรไว้
- จำนวนสื่ออ้างอิง: สำหรับ Reference-to-Video ให้จำนวนรายการรวมใน
images และ videos ไม่เกิน 5
- เสียงอ้างอิง: ใช้
audios เพื่อแนะนำอัตลักษณ์เสียงเท่านั้น และอธิบายเนื้อหาคำพูดที่ต้องการไว้ในพรอมต์