curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "grok-video-1.5",
"prompt": "A cinematic product shot with a slow camera push-in",
"video_generation_mode": "text_to_video",
"duration": 8,
"resolution": "720p",
"aspect_ratio": "16:9"
}'
import requests
response = requests.post(
"https://toapis.com/v1/videos/generations",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "grok-video-1.5",
"prompt": "A cinematic product shot with a slow camera push-in",
"video_generation_mode": "first_frame_image_to_video",
"image": "https://example.com/first-frame.jpg",
"duration": 8,
"resolution": "720p",
"aspect_ratio": "16:9"
},
)
response.raise_for_status()
print(response.json()["id"])
{
"id": "video_abc123def456",
"object": "generation.task",
"model": "grok-video-1.5",
"status": "queued",
"progress": 0,
"created_at": 1768380224,
"metadata": {}
}
Grok Video
Grok Video 1.5 動画生成
テキスト, 開始フレーム, または参照画像から動画を生成
POST
/
v1
/
videos
/
generations
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "grok-video-1.5",
"prompt": "A cinematic product shot with a slow camera push-in",
"video_generation_mode": "text_to_video",
"duration": 8,
"resolution": "720p",
"aspect_ratio": "16:9"
}'
import requests
response = requests.post(
"https://toapis.com/v1/videos/generations",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "grok-video-1.5",
"prompt": "A cinematic product shot with a slow camera push-in",
"video_generation_mode": "first_frame_image_to_video",
"image": "https://example.com/first-frame.jpg",
"duration": 8,
"resolution": "720p",
"aspect_ratio": "16:9"
},
)
response.raise_for_status()
print(response.json()["id"])
{
"id": "video_abc123def456",
"object": "generation.task",
"model": "grok-video-1.5",
"status": "queued",
"progress": 0,
"created_at": 1768380224,
"metadata": {}
}
中国本土から利用する場合は, 例の
https://toapis.com を https://toapis.cn に置き換えてください.grok-video-1.5 では次の 3 つの入力モードを指定できます. 対応チャネルで有効になっているモードだけが利用できます. 見積もりの取得に成功しても, 生成可能なチャネルがあるとは限りません.
画像には公開アクセス可能な
http:// または https:// URL を使ってください. ローカルファイルは先に画像アップロード APIでアップロードし, base64 は直接送信しないでください. JSON で URL を渡す方式は対応チャネル間で共通に使えます. 一部のチャネルは multipart のバイナリファイルを受け付けません.生成モード
| モード | 入力 |
|---|---|
text_to_video | プロンプトのみ, 画像なし |
first_frame_image_to_video | 開始フレーム 1 枚 |
reference_images_to_video | 参照画像 1-7 枚, 1 枚の場合も含む |
video_generation_mode を明示してください. 省略すると従来の単一画像の扱いが維持され, reference_images が 1 枚だけの場合は参照モードになりません. テキストモードでは画像を送信できません.
認証
string
必須
API キーを Bearer Token として指定してください.
Authorization: Bearer YOUR_API_KEY
リクエストパラメータ
string
デフォルト:"grok-video-1.5"
必須
公開モデル名
grok-video-1.5 を使い, 供給元のモデル名に置き換えないでください.string
シーンと動きを指定します. テキストと参照画像のモードでは必須です. 従来の単一フレームリクエストの一部では省略できますが, それ以外では必要な場合があります. 新しい連携では空でないプロンプトを指定してください.
string
従来のクライアントでは省略できます. 実際の入力に合う値を選びます: テキストのみは
text_to_video, 開始フレームが 1 枚は first_frame_image_to_video, 参照画像が 1-7 枚は reference_images_to_video. モードは image, input_reference または reference_images の実際の入力と一致する必要があり, 一致しない場合は拒否されます. 参照画像が 1 枚の場合は, 従来の開始フレーム入力と区別するため参照モードを明示してください.string
開始フレームの URL. 開始フレームモードで必須ですが, 代わりに
input_reference を使えます. テキストと参照画像のみのモードでは省略します. 開始フレームの上流での扱いはチャネルによって異なります.string
開始フレーム URL の文字列エイリアス.
image とどちらか一方を使い, 異なる値を両方に設定しないでください. 新しいリクエストでこのフィールドを使う場合はモードも明示してください.array
参照画像 1-7 枚の URL. 文字列配列または
{"url":"https://example.com/reference.jpg"} のオブジェクト配列を使えます. 参照モードで必須です. 従来の image_urls と images も利用できますが, 内容の異なる複数のリストを同時に送信しないでください.integer
整数の秒数を明示してください. 1-15 秒に対応します.
string
参照画像モードでは
480p または 720p を使います. テキストと開始フレームモードでは対応チャネルで 1080p を使えます. このページの例では 720p を明示しています.string
動画の縦横比, 例:
16:9. 一般的な値は 1:1, 16:9, 9:16, 3:2, 2:3 です. 対応範囲はチャネルによって異なります.互換性の制限
一部のチャネルでは単一の開始フレームと単一の参照画像を同じ方法で処理します. モード名だけでは厳密な開始フレーム制御を保証しません. モードが有効でもプロトコルの制限は適用されます. 未対応の入力は送信前に拒否される場合があり, 対応する有効なチャネルがなければ生成できません.料金
動画料金は現在のアカウントと SKU 設定に従います. 現在の料金と認証済みのパラメータ別見積もりを確認してください. このページは固定の秒単価を保証しません.動画タスクの作成
例ではモード, 長さ, 解像度を明示しています. 画像 URL を実際にアクセスできるものに置き換えてください.curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "grok-video-1.5",
"prompt": "A cinematic product shot with a slow camera push-in",
"video_generation_mode": "text_to_video",
"duration": 8,
"resolution": "720p",
"aspect_ratio": "16:9"
}'
import requests
response = requests.post(
"https://toapis.com/v1/videos/generations",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "grok-video-1.5",
"prompt": "A cinematic product shot with a slow camera push-in",
"video_generation_mode": "first_frame_image_to_video",
"image": "https://example.com/first-frame.jpg",
"duration": 8,
"resolution": "720p",
"aspect_ratio": "16:9"
},
)
response.raise_for_status()
print(response.json()["id"])
参照画像の例
{
"model": "grok-video-1.5",
"prompt": "A cinematic product shot with a slow camera push-in",
"video_generation_mode": "reference_images_to_video",
"reference_images": [
"https://example.com/reference-a.jpg",
"https://example.com/reference-b.jpg"
],
"duration": 8,
"resolution": "720p",
"aspect_ratio": "16:9"
}
レスポンス
string
ポーリング用のタスク ID.
string
オブジェクト種別:
generation.task.string
リクエストの公開モデル名.
string
状態:
queued, in_progress, completed, failed.{
"id": "video_abc123def456",
"object": "generation.task",
"model": "grok-video-1.5",
"status": "queued",
"progress": 0,
"created_at": 1768380224,
"metadata": {}
}
タスクの状態確認
返されたid を動画タスク状態 APIに渡してください.