Sand AI の動画生成モデル Magi 2 の API リファレンスです。
モデルの種類
この API は次の 3 種類のモデルに対応しています。
Magi 2 Text to Video
エンドポイント {#}
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: '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
リクエストパラメータ
必須パラメータ
任意パラメータ
リクエスト例
{
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
リクエストパラメータ
必須パラメータ
参照メディア
参照メディアはすべて任意で、1 回のリクエストで組み合わせて使用できます。3 つの配列をすべて省略すると、モデルはプロンプトのみから動画を生成します。
@ (AT) 参照用プレースホルダー
@ (AT) 参照では、プロンプト内に番号付きの <<<...>>> プレースホルダーを記述します。番号はメディアの種類ごとに 1 から始まり、各配列の順序に従います。
任意パラメータ
リクエスト例
{
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']
}
@ (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']
}
レスポンス形式
初回のレスポンス
すべてのモデルがポーリング用の 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:動画の生成に失敗しました
ベストプラクティス
- プロンプト:シーン、動き、カメラワーク、入れたい音を記述します
- フレーム画像:画像から動画を生成する場合は、
image_end_url を指定する場合も必ず image_url を指定します
- 参照順序:
images、videos、audios の各要素は、prompt 内で参照したい順序で並べます
- 音声:無音の動画を生成するには
sound を false に設定します