MAGI-2 動画生成
テキスト、先頭/末尾フレーム画像、または画像・動画・音声のマルチモーダル参照から 1080p の同期音声付き MP4 動画を生成(4-30 秒)
中国本土のユーザーへ: 中国本土からは https://toapis.cn を API エンドポイント(Base URL)としてご利用いただき、例中の https://toapis.com を https://toapis.cn に置き換えてください。中国本土サイトでは、タスク照会および Webhook で返されるメディア URL が自動的に中国本土ドメインへ書き換えられます。
- プラットフォームモデル名:
magi-2(3 つのモードを単一モデル名で提供し、トップレベルのvideo_generation_modeで切り替え) - 出力仕様:同期音声(セリフ・効果音・環境音)付き
1080pMP4 動画、長さ4-30秒の任意整数 - 課金方式:正常に生成された動画の秒数に応じて課金されます。3 つのモードで同じ課金ルールが適用され、無音(
generate_audio: false)でも課金ルールは変わらず、参照素材は入力項目として個別課金されず、失敗したタスクは課金されません - 提供範囲:グローバルサイト(
https://toapis.com)および中国本土サイト(https://toapis.cn)の両方で利用可能 - 非同期タスク API:送信後に統一形式の
generation.taskを返します。GET /v1/videos/generations/{task_id}またはGET /v1/tasks/{task_id}で結果を取得してください
本モデルは厳格なトップレベルフラット JSON ホワイトリストを適用します。画像からの生成を含む全モードで prompt は必須かつ空欄不可です。メディア入力からモードを自動推測せず、ネストされたラッパー(input、options、config、metadata)、旧エイリアス、未定義パラメータ、Base64/Data URI、multipart アップロードは HTTP 400 で拒否されます。
入力モード
video_generation_mode |
モード | 素材要件 | aspect_ratio |
|---|---|---|---|
text_to_video(デフォルト) |
テキスト生成 | image_urls、last_frame_url、video_urls、audio_urls は指定不可 |
任意、6 種類、デフォルト 16:9 |
first_frame_image_to_video |
先頭/末尾フレーム生成 | image_urls 必須(先頭フレーム 1 枚のみ);last_frame_url 任意;video_urls / audio_urls は指定不可 |
任意、6 種類;省略時は先頭フレームに従う |
reference_to_video |
マルチモーダル参照生成 | image_urls(1-10 枚)、video_urls(1-5 本)、audio_urls(1-5 本)のうち少なくとも 1 つを指定(併用可);last_frame_url は指定不可 |
任意、6 種類、デフォルト 16:9 |
認証
すべてのエンドポイントで Bearer Token 認証が必要です。
Authorization: Bearer <token>リクエストパラメータ
プラットフォームの動画生成モデル名。全モード共通で magi-2 固定です。
動画生成モード。デフォルトは text_to_video。
text_to_video:テキスト生成(メディアフィールド不可)first_frame_image_to_video:先頭フレーム(任意で末尾フレーム)画像生成reference_to_video:画像・動画・音声によるマルチモーダル参照生成
メディア入力を渡す場合は必ず対応するモードを明示してください。image_urls からモードを自動推測しません。
動画の内容説明。前後空白除去後 1-8000 Unicode 文字。画像生成を含む全モードで必須(空欄不可)です。 被写体、動作、カメラワーク、セリフ(引用符で表記)、効果音、環境音を記述してください。
動画の長さ(秒)。4 から 30 の整数、デフォルトは 5。生成秒数に応じて課金されます。
出力動画のアスペクト比。対応値:21:9、16:9、4:3、1:1、3:4、9:16。
text_to_videoとreference_to_video:デフォルト16:9first_frame_image_to_video:任意;省略時は先頭フレーム画像の比率に自動で従います
出力解像度。1080p のみ対応し、他の値は拒否されます。
同期音声(セリフ・効果音・環境音)を生成するかどうか。デフォルトは true。false で無音動画になりますが、課金ルールは同じです。
任意の乱数シード。0 から 2147483647 の整数(両端含む)。省略時はランダム、明示的な 0 は保持され、負数は拒否されます。
公開アクセス可能な HTTP(S) 画像 URL 配列(JPG / PNG / WEBP)。ローカル画像は事前に 画像アップロード で URL を取得してください。
text_to_video:指定不可first_frame_image_to_video:必須、先頭フレームとしてちょうど1枚reference_to_video:任意、1-10枚の参照画像(先頭フレームとしては解釈されません)
未使用時はフィールド自体を省略してください。空配列 [] や null は HTTP 400 になります。
終了画面を指定する単一の公開 HTTP(S) 画像 URL(JPG / PNG / WEBP)。
first_frame_image_to_video で image_urls と併用する場合のみ有効です。text_to_video と reference_to_video では指定不可です。
参照動画の公開 HTTP(S) URL 配列(MP4 / MOV)、1-5 本。ローカル動画は事前に 動画アップロード で URL を取得してください。
reference_to_videoのみ有効;text_to_videoとfirst_frame_image_to_videoでは指定不可- 各動画は
2-30秒、参照動画の合計長さは<= 30秒としてください(送信時は URL と本数上限を検証し、長さ制約は生成処理時に検証されます)
参照音声の公開 HTTP(S) URL 配列(MP3 / WAV)、1-5 本。ローカル音声は事前に 音声アップロード で URL を取得してください。
reference_to_videoのみ有効;text_to_videoとfirst_frame_image_to_videoでは指定不可- 各音声は
2-30秒、参照音声の合計長さは<= 30秒としてください(送信時は URL と本数上限を検証し、長さ制約は生成処理時に検証されます)
注文番号や取引 ID などの任意の業務識別子。同じステータス照会エンドポイントでこの値からタスクを取得できます。
任意の ToAPIs タスク完了コールバック URL(callback_url も互換サポート)。プラットフォームが HMAC-SHA256 署名付きで配信します。詳細は タスク Webhook を参照してください。
素材ルールと検証境界
- すべてのメディア入力は公開アクセス可能な
http://またはhttps://URL のみ受け付けます。プライベート/ループバックアドレス、認証情報埋め込み URL、Data URI、Base64、multipart アップロードは拒否されます。 reference_to_videoではimage_urls、video_urls、audio_urlsのうち少なくとも 1 つを空でない配列で指定してください。3 種類は自由に組み合わせ可能です。- 未使用の任意メディア配列は空配列
[]やnullを渡さず省略してください。 - ネストされたラッパー(
input、options、config、metadata)、旧エイリアス(seconds、size、ratio、audio、audio_setting、image、images、reference_images)、stream、n、fps、watermark、return_last_frame、negative_prompt、範囲外のseed/duration、未対応のresolution/aspect_ratio、モード不整合は HTTP400で拒否されます。
課金ルール
| 項目 | 内容 |
|---|---|
| 課金方式 | 成功出力動画の秒数課金(per_second、4-30 整数秒) |
| モード適用 | text_to_video、first_frame_image_to_video、reference_to_video の 3 モードで同じ課金ルールを適用 |
| 音声・参照素材 | generate_audio: false(無音)でも課金ルールは変わりません;参照画像/動画/音声は入力項目として個別課金されません |
| 失敗・確定精算 | タスク失敗時は課金なし(事前仮押さえ分は返金);最終精算は完了時の billing(status: "settled" / "refunded")と usage(charge_type: "per_second"、output_seconds)で確認してください |
送信レスポンスにはタスク ID のみが含まれ、確定料金は含まれません。実際の利用可否とアカウント課金詳細はご利用サイトのコンソールおよび最終タスク状態の billing / usage をご確認ください。
リクエスト例
テキスト生成(明示的な seed: 0 を指定)
{
"model": "magi-2",
"video_generation_mode": "text_to_video",
"prompt": "A small boat crosses a quiet lake at sunrise, with gentle water sounds and distant birds.",
"duration": 5,
"aspect_ratio": "16:9",
"resolution": "1080p",
"generate_audio": true,
"seed": 0
}先頭/末尾フレーム画像生成(無音、aspect_ratio なし)
{
"model": "magi-2",
"video_generation_mode": "first_frame_image_to_video",
"prompt": "The camera slowly pushes toward the subject and transitions smoothly into the ending composition.",
"image_urls": [
"https://example.com/first-frame.jpg"
],
"last_frame_url": "https://example.com/last-frame.jpg",
"duration": 5,
"resolution": "1080p",
"generate_audio": false
}マルチモーダル参照生成(画像 + 動画 + 音声)
{
"model": "magi-2",
"video_generation_mode": "reference_to_video",
"prompt": "Keep the subject from the reference image, follow the camera movement from the reference video, and match the mood of the reference audio.",
"image_urls": [
"https://example.com/reference-subject.jpg"
],
"video_urls": [
"https://example.com/reference-motion.mp4"
],
"audio_urls": [
"https://example.com/reference-ambience.wav"
],
"duration": 5,
"aspect_ratio": "16:9",
"resolution": "1080p",
"generate_audio": true
}レスポンス
タスクステータスの照会に使用する ToAPIs タスク ID。
オブジェクトタイプ。常に generation.task。
このリクエストで使用されたプラットフォームモデル名。常に magi-2。
タスクステータス:queued、in_progress、completed、failed のいずれか。
タスク進捗(0 から 100 のパーセント)。
タスク作成時刻(Unix 秒タイムスタンプ)。
送信後は 動画タスクステータスの取得(GET /v1/videos/generations/{task_id}、GET /v1/tasks/{task_id} 互換)をポーリングするか、タスク Webhook を設定してください。完了後、MP4 動画 URL は result.data[0].url に返されます。ポーリング間隔は 5-10 秒以上(ジッター付き)とし、HTTP 429 時は Retry-After に従ってください。
リクエスト例
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "magi-2",
"video_generation_mode": "text_to_video",
"prompt": "A small boat crosses a quiet lake at sunrise, with gentle water sounds.",
"duration": 5,
"aspect_ratio": "16:9",
"resolution": "1080p",
"generate_audio": true,
"seed": 0
}'curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "magi-2",
"video_generation_mode": "first_frame_image_to_video",
"prompt": "The camera slowly pushes in and transitions smoothly to the ending frame.",
"image_urls": [
"https://example.com/first-frame.jpg"
],
"last_frame_url": "https://example.com/last-frame.jpg",
"duration": 5,
"resolution": "1080p",
"generate_audio": false
}'curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "magi-2",
"video_generation_mode": "reference_to_video",
"prompt": "Keep the subject from the reference image, use the camera motion from the video, and match the ambience from the audio.",
"image_urls": [
"https://example.com/reference-subject.jpg"
],
"video_urls": [
"https://example.com/reference-motion.mp4"
],
"audio_urls": [
"https://example.com/reference-ambience.wav"
],
"duration": 5,
"aspect_ratio": "16:9",
"resolution": "1080p",
"generate_audio": true
}'import requests
response = requests.post(
"https://toapis.com/v1/videos/generations",
headers={
"Authorization": "Bearer <token>",
"Content-Type": "application/json",
},
json={
"model": "magi-2",
"video_generation_mode": "reference_to_video",
"prompt": "Keep the subject from the reference image and show it moving in a sunlit garden.",
"image_urls": ["https://example.com/reference-subject.jpg"],
"duration": 5,
"aspect_ratio": "16:9",
"resolution": "1080p",
"generate_audio": True,
},
)
print(response.json())const response = await fetch("https://toapis.com/v1/videos/generations", {
method: "POST",
headers: {
Authorization: "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "magi-2",
video_generation_mode: "text_to_video",
prompt: "A small boat crosses a quiet lake at sunrise, with gentle water sounds.",
duration: 5,
aspect_ratio: "16:9",
resolution: "1080p",
generate_audio: true
})
});
console.log(await response.json());レスポンス例
{
"id": "tsk_vid_01M840FXWTM23BKN1JR68C5XEM",
"object": "generation.task",
"model": "magi-2",
"status": "queued",
"progress": 0,
"created_at": 1795575600
}