Referensi API lengkap untuk model pembuat video Magi 2 dari Sand AI.
Varian Model
API ini mendukung tiga varian model:
Magi 2 Text to Video
Endpoint
POST /api/v1/video/task
Parameter Permintaan
Wajib
Opsional
Contoh Permintaan
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: 'magi-2-text-to-video',
prompt: 'The camera glides toward a lighthouse at dusk as waves crash against the rocks',
duration: 8,
aspect_ratio: '16:9',
sound: true
})
});
const { data } = await response.json();
const taskId = data.task_id;
Magi 2 Image to Video
Parameter Permintaan
Wajib
Opsional
Contoh Permintaan
{
model_name: 'magi-2-image-to-video',
image_url: 'https://example.com/first-frame.jpg',
image_end_url: 'https://example.com/last-frame.jpg',
prompt: 'The camera slowly pulls back to reveal a waterfall and the forest around it',
duration: 8,
aspect_ratio: '16:9',
sound: false
}
Magi 2 Reference to Video
Parameter Permintaan
Wajib
Media Referensi
Semua media referensi bersifat opsional dan dapat digabungkan dalam satu permintaan. Jika ketiga larik tidak disertakan, model membuat video hanya berdasarkan prompt.
Penanda Referensi @ (AT)
Fitur referensi @ (AT) menggunakan penanda <<<...>>> bernomor dalam prompt. Untuk setiap jenis media, penomoran dimulai dari 1 dan mengikuti urutan dalam larik masing-masing.
Opsional
Contoh Permintaan
{
model_name: 'magi-2-reference-to-video',
prompt: 'Use the reference image for the subject, the reference video for the camera movement, and the reference audio for the ambience',
duration: 8,
aspect_ratio: '16:9',
sound: true,
images: ['https://example.com/subject-reference.jpg'],
videos: ['https://example.com/camera-movement-reference.mp4'],
audios: ['https://example.com/ambience-reference.mp3']
}
Contoh Permintaan Pembuatan Video dengan Referensi @ (AT)
{
model_name: 'magi-2-reference-to-video',
prompt: 'Show the cyclist from <<<image_1>>> on the trail in <<<image_2>>>. Follow the camera movement in <<<video_1>>> and use <<<audio_1>>> as a reference for the forest ambience',
duration: 10,
aspect_ratio: '16:9',
sound: true,
images: [
'https://example.com/cyclist-reference.jpg',
'https://example.com/forest-trail-reference.png'
],
videos: ['https://example.com/camera-movement-reference.mp4'],
audios: ['https://example.com/forest-ambience-reference.mp3']
}
Respons Awal
Semua model mengembalikan task_id untuk memeriksa status secara berkala:
{
"code": 0,
"message": "success",
"data": {
"task_id": "{task_id}",
"response_url": "https://api.flaq.ai/api/v1/video/{task_id}",
"task_status": "submitted"
}
}
Respons Pemeriksaan Status
Panggil GET /api/v1/video/{taskId} secara berkala untuk memeriksa status:
{
"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"
}
]
}
}
}
Nilai Status
submitted: Tugas telah diterima dan menunggu untuk diproses
processing: Pembuatan video sedang berlangsung
succeed: Pembuatan video selesai
failed: Pembuatan video gagal
Praktik Terbaik
- Prompt: Jelaskan adegan, aksi, teknik pengambilan gambar, dan suara yang ingin Anda dengar
- Gambar bingkai: Selalu sertakan
image_url saat membuat video dari gambar, termasuk ketika Anda menyertakan image_end_url
- Urutan referensi: Susun
images, videos, dan audios sesuai urutan yang ingin Anda rujuk dalam prompt
- Suara: Atur
sound ke false jika Anda ingin membuat video tanpa suara