curl --request POST \
--url https://api.apimart.ai/v1/videos/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "magi-2",
"prompt": "雨の夜、赤い紙の船が側溝を流れる。マクロ撮影と雨音",
"duration": 5,
"aspect_ratio": "9:16",
"generate_audio": true,
"nsfw_check": true
}'
import requests
payload = {
"model": "magi-2",
"prompt": "雨の夜、赤い紙の船が側溝を流れる。マクロ撮影と雨音",
"duration": 5,
"aspect_ratio": "9:16",
"generate_audio": True,
"nsfw_check": True
}
response = requests.post(
"https://api.apimart.ai/v1/videos/generations",
headers={"Authorization": "Bearer <token>"},
json=payload,
timeout=60,
)
response.raise_for_status()
print(response.json())
const payload = {
"model": "magi-2",
"prompt": "雨の夜、赤い紙の船が側溝を流れる。マクロ撮影と雨音",
"duration": 5,
"aspect_ratio": "9:16",
"generate_audio": true,
"nsfw_check": true
};
const response = await fetch("https://api.apimart.ai/v1/videos/generations", {
method: "POST",
headers: {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_example_magi2"
}
]
}
MAGI-2
MAGI-2 動画生成
テキスト、開始・終了フレーム、画像・動画・音声の参照から動画を生成。出力は 1080p 固定、長さは 4–30 秒、音声生成はデフォルトで有効です。
POST
/
v1
/
videos
/
generations
curl --request POST \
--url https://api.apimart.ai/v1/videos/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "magi-2",
"prompt": "雨の夜、赤い紙の船が側溝を流れる。マクロ撮影と雨音",
"duration": 5,
"aspect_ratio": "9:16",
"generate_audio": true,
"nsfw_check": true
}'
import requests
payload = {
"model": "magi-2",
"prompt": "雨の夜、赤い紙の船が側溝を流れる。マクロ撮影と雨音",
"duration": 5,
"aspect_ratio": "9:16",
"generate_audio": True,
"nsfw_check": True
}
response = requests.post(
"https://api.apimart.ai/v1/videos/generations",
headers={"Authorization": "Bearer <token>"},
json=payload,
timeout=60,
)
response.raise_for_status()
print(response.json())
const payload = {
"model": "magi-2",
"prompt": "雨の夜、赤い紙の船が側溝を流れる。マクロ撮影と雨音",
"duration": 5,
"aspect_ratio": "9:16",
"generate_audio": true,
"nsfw_check": true
};
const response = await fetch("https://api.apimart.ai/v1/videos/generations", {
method: "POST",
headers: {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_example_magi2"
}
]
}
curl --request POST \
--url https://api.apimart.ai/v1/videos/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "magi-2",
"prompt": "雨の夜、赤い紙の船が側溝を流れる。マクロ撮影と雨音",
"duration": 5,
"aspect_ratio": "9:16",
"generate_audio": true,
"nsfw_check": true
}'
import requests
payload = {
"model": "magi-2",
"prompt": "雨の夜、赤い紙の船が側溝を流れる。マクロ撮影と雨音",
"duration": 5,
"aspect_ratio": "9:16",
"generate_audio": True,
"nsfw_check": True
}
response = requests.post(
"https://api.apimart.ai/v1/videos/generations",
headers={"Authorization": "Bearer <token>"},
json=payload,
timeout=60,
)
response.raise_for_status()
print(response.json())
const payload = {
"model": "magi-2",
"prompt": "雨の夜、赤い紙の船が側溝を流れる。マクロ撮影と雨音",
"duration": 5,
"aspect_ratio": "9:16",
"generate_audio": true,
"nsfw_check": true
};
const response = await fetch("https://api.apimart.ai/v1/videos/generations", {
method: "POST",
headers: {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_example_magi2"
}
]
}
POST /v1/videos/generations に送信し、data[0].task_id を取得してからタスク照会 APIで結果を確認します。
生成モード
| モード | 送信方法 |
|---|---|
| テキストから動画 | prompt を指定し、画像・動画・音声素材は送信しません。 |
| 画像から動画 | image_urls で開始フレームと任意の終了フレームを送信するか、専用のフレームフィールドを使用します。 |
| 参照から動画 | video_urls、audio_urls、または role: "reference_image" の画像があると自動で参照モードになります。image_urls のみの場合は omni_reference_task_type: "reference" を明示してください。 |
reference の動作は同じです。参照モードでは全画像を参照として扱い、image_urls と image_with_roles 内の role: "reference_image" の画像は合計最大 10 枚です。
参照生成の例では omni_reference_task_type: "reference" を明示しています。各素材の用途をプロンプトで説明してください。素材は生成の参考となり、元動画の直接結合や元音声のそのままの再利用は行いません。
リクエストパラメータ
動画タスクを送信する前にコンテンツモデレーションを実行するかどうかを指定します。
true:omni-moderation-latestでプロンプトと入力画像を審査falseまたは省略:審査リクエストを行わず、審査コストや遅延を追加しない(デフォルト)
テキスト・参照モードは
16:9(デフォルト)、9:16、1:1、4:3、3:4、21:9。画像から動画は前の 5 種のみで 21:9 は非対応。省略または auto で開始フレームの比率に従い、解像度は 1080p のままです。auto(デフォルト)と reference に対応。複数の image_urls を参照に使う場合は reference を明示します。edit / extend は非対応です。各項目は公開 HTTP(S) 画像 URL です。最大 2 枚という制限は画像から動画の場合のみで、開始フレームと任意の終了フレームを指定します。このモードは、画像のみを送り、参照動画・音声、明示的な
reference、reference_image ロールがない場合に適用されます。参照モードでは配列全体が参照となり、image_with_roles の reference_image と合計最大 10 枚です。自動選択と明示指定で上限は同じです。各項目に
url(公開 HTTP(S) 画像 URL)と role を指定します。ロールは first_frame、last_frame、reference_image。画像から動画では開始・終了フレームは各 1 枚まで。reference_image は参照モードを選択し、その画像と image_urls の画像を合わせて最大 10 枚です。参照動画は最大 5 本、各 2–30 秒。合計は 30 秒以内にしてください。超過分は上流サービスで切り詰められる場合があります。公開 HTTP(S) URL の配列を使用し、単数の
video_url は使えません。素材の要件
素材は公開された直接アクセス可能な HTTP(S) URL を使用します。ログイン・直リンク制限・ダウンロード失敗はタスク失敗の原因になります。ローカルファイルは画像、動画、音声のアップロード API で URL を取得できます。リクエスト例
開始・終了フレーム
{
"model": "magi-2",
"prompt": "少女がゆっくり振り向き、柔らかな光の中で終了フレームの姿勢へ滑らかに移る",
"image_urls": [
"https://example.com/start.jpg",
"https://example.com/end.jpg"
],
"duration": 5
}
aspect_ratio の省略時はその比率に従います。image_urls の代わりに first_frame_image と last_frame_image も使用できます。
画像のみの参照
{
"model": "magi-2",
"prompt": "2 枚の参照画像の人物が同じ庭で出会い、それぞれの外見を保つ",
"image_urls": [
"https://example.com/reference-1.jpg"
],
"image_with_roles": [
{
"url": "https://example.com/reference-2.jpg",
"role": "reference_image"
}
],
"omni_reference_task_type": "reference",
"aspect_ratio": "16:9",
"duration": 5
}
画像・動画・音声の混合参照
{
"model": "magi-2",
"prompt": "参照動画のカメラワーク、画像の少女の外見、音声の音楽スタイルを参考に夕暮れの海辺を歩く場面を生成",
"image_urls": [
"https://example.com/girl.jpg"
],
"video_urls": [
"https://example.com/camera.mp4"
],
"audio_urls": [
"https://example.com/bgm.mp3"
],
"omni_reference_task_type": "reference",
"aspect_ratio": "16:9",
"duration": 8
}
タスクの照会と結果
タスク照会 APIをcompleted または failed までポーリングします。通常は数分かかり、混雑時はさらに長くなる場合があります。一定時間の経過だけで失敗と判断しないでください。照会を停止してもタスクは取消されません。
curl --request GET \
--url 'https://api.apimart.ai/v1/tasks/task_example_magi2' \
--header 'Authorization: Bearer <token>'
| フィールド | 説明 |
|---|---|
data.status | pending / processing は処理中、completed は成功、failed は失敗。 |
data.progress | 進捗、0–100。 |
data.result.videos[0].url | プラットフォームの保存領域に転送された生成動画の URL。詳細な構造はタスク照会 API を参照。 |
data.error.message | タスク失敗時の詳細。 |
非対応の機能
以下を送信すると HTTP 400 になります:mode, negative_prompt, watermark: true, camera_control, multi_shot / multi_prompt, element_list, video_list, voice_list, audio_setting, keyframe, omni_reference_task_type: "edit" / "extend", video_url. resolution は 1080p のみ。動画編集・延長と中間フレームには対応していません。
よくあるエラー
送信失敗はerror.message、作成後のタスク失敗は照会結果の data.error.message を確認してください。
| エラーメッセージ・状況 | 対処 |
|---|---|
duration must be between 4 and 30 whole seconds | 4–30 の整数秒を使用。省略時は 5。 |
duration (5) and seconds (6) are aliases and must match | 時長の別名は同じ値にするか、片方のみ送信。 |
requires prompt | すべてのモードでプロンプトを指定。 |
image_urls takes at most 2 images | 開始・終了は最大 2 枚。画像のみの参照では reference を明示。 |
image-to-video only supports aspect_ratio | 画像から動画では 21:9 を削除。省略または auto で開始フレームの比率を使用。 |
accepts at most 10 reference images / 5 videos / 5 audios | 参照画像は 10 枚、動画は 5 本、音声は 5 件まで。 |
has no video edit / extend / does not support keyframes | 編集・延長・中間フレームを削除。参照動画は video_urls。 |
always outputs 1080p | 1080p のみを送信するか resolution を省略。 |
audio (true) and generate_audio (false) are aliases and must match | 音声スイッチの値をそろえるか片方のみ送信。 |
Could not download the input... | 直接ダウンロードできる公開 URL を確認して再送信。 |