メインコンテンツへスキップ
POST
Submit a video generation task (text-to-video / image-to-video)
🔒 申請制のGrokOfficialグループが必要です: Grok Imagine VideoはDefaultグループには含まれておらず、呼び出す前にアクセス権の申請が必要です(このページのPlaygroundを含みます)。アクセス権がない場合や、リクエスト単位課金のTokenを使用している場合、すべての呼び出しで503が返されます。Grok Imagine Videoの概要 - グループ設定を参照してください。
右側のインタラクティブなPlaygroundを使用すると、エンドポイントを直接テストできます。AuthorizationにAPI Keyを入力し(形式: Bearer sk-xxx)、modelを選択して、prompt / seconds / sizeを入力して送信します。画像から動画への生成にはinput_referenceを追加してください。Playgroundではステップ1(送信)のみが実行されます。タスクidを取得した後は、以下に示すようにポーリングしてダウンロードを行ってください。
⚠️ よくある3つの落とし穴
  1. size / secondsを指定しない場合、デフォルトは480pおよび8秒となり、その内容で課金されます。
  2. grok-imagine-videoには1080pがありません: 1920x1080は400を返します。1080pには-1.5または-1.5-liteを使用してください。
  3. モデレーションによるブロックも課金対象です: ブロックされたタスクでもcompletedが返されますが、error.code: "moderation_blocked"が含まれ、動画は生成されません。
非同期の3ステップフロー — このページではステップ1(送信)のみを説明します
  • ステップ1(このページ): POST /v1/videos → タスクid + status: "queued"を返却
  • ステップ2: statusが"completed"または"failed"になるまでGET /v1/videos/{id}をポーリング
  • ステップ3: GET /v1/videos/{id}/contentからMP4をダウンロード
送信リクエストは数秒以内に返され、動画の生成完了を待つことはありません。

コード例

Python(テキストから動画生成、全3ステップ)

Python(画像から動画生成、base64入力画像)

cURL

Node.js(fetch)

パラメータクイックリファレンス

1秒あたりの料金(xAIと同額):
モデルの価格設定は公式サイトに準拠しており、公式側の変更に伴い改定される場合があります。上記の表は参考用であり、トップナビゲーションのモデル価格タブが正式な情報となります:モデル価格。

レスポンス例

送信(ステップ1):
完了(ステップ2のポーリング結果):
モデレーションによるブロック: status は依然として completed ですが、追加の error フィールドが存在し、ダウンロードできる動画はありません:

関連ドキュメント

承認

Authorization
string
header
必須

API Key from the APIYI console (Token group must include GrokOfficial)

ボディ

application/json
model
enum<string>
デフォルト:grok-imagine-video-1.5-lite
必須

Model ID (billed per second × resolution rate):

  • grok-imagine-video — 480p $0.05/s, 720p $0.07/s, no 1080p
  • grok-imagine-video-1.5 — 480p $0.08, 720p $0.14, 1080p $0.25 per second
  • grok-imagine-video-1.5-lite — 480p $0.02, 720p $0.03, 1080p $0.14 per second
利用可能なオプション:
grok-imagine-video,
grok-imagine-video-1.5,
grok-imagine-video-1.5-lite
prompt
string

Prompt: scene + subject + action + camera + lighting. Required for text-to-video; for image-to-video it describes motion and camera

例:

"a red paper boat drifting on a calm lake, gentle ripples, soft morning light"

seconds
string

Duration from 1 to 15 seconds, as a string or a number; default 8. Out-of-range values return 400. Cost scales with seconds — use 1–2 seconds while testing.

例:

"2"

size
enum<string>
デフォルト:854x480

Output size in WIDTHxHEIGHT pixels: the shorter side sets the resolution (≥1080 is 1080p, ≥720 is 720p, otherwise 480p) and the aspect ratio snaps to the nearest supported one. You can also pass 480p / 720p / 1080p directly. Without it, the default is 480p.

  • 854x480 — 480p landscape (measured 848×480)
  • 1280x720 / 720x1280 — 720p landscape / portrait
  • 1920x1080 / 1080x1920 — 1080p (1.5 / 1.5-lite only)
利用可能なオプション:
854x480,
480x854,
1280x720,
720x1280,
1920x1080,
1080x1920
input_reference
string

Input image for image-to-video: a public image URL or a data:image/jpeg;base64,... data URI. Passing it makes the job image-to-video, and the output frame follows the input image. Each input image costs an extra $0.002 (grok-imagine-video) or $0.01 (1.5 / 1.5-lite).

例:

"https://example.com/first-frame.jpg"

レスポンス

Task submitted; returns the task id and queued status

id
string

Task ID for polling and download

例:

"task_xxxxxxxxxxxxxxxx"

object
string

Always video

例:

"video"

model
string
例:

"grok-imagine-video-1.5-lite"

status
enum<string>

Task status:

  • queued — submitted, waiting
  • in_progress — generating
  • completed — done, download from /v1/videos/{id}/content; with error.code: moderation_blocked it was blocked and has no video
  • failed — failed
利用可能なオプション:
queued,
in_progress,
completed,
failed
例:

"queued"

progress
integer

Progress 0–100, coarse-grained; not suitable for a precise progress bar

例:

0

seconds
string

Video duration, returned once done

created_at
integer

Task creation Unix timestamp (seconds)

completed_at
integer

Task completion Unix timestamp (seconds), returned once done