WorldRouter

Skip to Content

Generate Videos with Grok

What you can do

Use WorldRouter’s async video task API to generate videos with xAI Grok. The flow is simple: create a task, poll until it reaches a terminal state, then download the output video from the task response.

Before you start

  • You need a team-scoped API key with available credits.
  • Use the same base URL from Quickstart. Grok video lives under the OpenAI-compatible /v1 surface.
  • Grok video requests are asynchronous. A successful create request returns a task id; the video is only ready after the task status becomes succeeded.
Tip:

Start from Quickstart if you still need an API key or the base URL. Use the same origin shown there: https://inference-api-pre-d80ca3.worldrouter.ai. Grok video uses the OpenAI-compatible /v1/videos/generations routes.

Supported models

These are the request model names you send in the model field:

ModelBest for
grok-imagine-videoStandard text-to-video generation.
grok-imagine-video-1.5-previewImage-guided generation — start from an input image.

Grok accepts a resolution of 480p or 720p, defaulting to 720p. Any other value — or an omitted one — falls back to 720p rather than returning an error.

Quick start flow

  1. 1Create a video task with POST /videos/generations.
  2. 2Save the returned task id.
  3. 3Poll GET /videos/generations/{task_id} until the task reaches a terminal state.
  4. 4When status becomes succeeded, download the video from content.video_url.

Create a task

Grok request bodies use lowercase fields. WorldRouter forwards these requests to xAI’s video surface through the async task API.

Use grok-imagine-video for standard text-to-video generation:

curl
curl -X POST "https://inference-api-pre-d80ca3.worldrouter.ai/v1/videos/generations" \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
  "model": "grok-imagine-video",
  "prompt": "A drone flyover of a snowy mountain range at sunrise.",
  "duration": 6,
  "resolution": "720p"
}'

Typical create response:

200 OK
{
"id": "task_123",
"request_id": "task_123",
"model": "grok-imagine-video",
"status": "queued"
}

Use grok-imagine-video-1.5-preview when you want to start from an input image:

JSON body
{
"model": "grok-imagine-video-1.5-preview",
"prompt": "Pan slowly across the scene.",
"resolution": "720p",
"image": {
  "url": "https://your-host.example.com/start.png"
}
}
Warning:

grok-imagine-video-1.5-preview requires an image.url. A request without one returns 400 invalid_request. Grok video input is not supported yet, so only text and image inputs are accepted.

Check task status

Poll the task until it reaches a terminal state. Use the task id returned by the create response:

curl
curl "https://inference-api-pre-d80ca3.worldrouter.ai/v1/videos/generations/task_123" \
-H "Authorization: Bearer your_api_key"

Typical status response:

200 OK
{
"id": "task_123",
"request_id": "task_123",
"model": "grok-imagine-video",
"status": "succeeded",
"content": {
  "video_url": "https://media.example.com/output.mp4"
}
}

WorldRouter normalizes task states into:

  • queued
  • running
  • succeeded
  • failed
  • cancelled
  • expired

Download the output

Only download the result after the task status becomes succeeded:

curl
curl -L "https://media.example.com/output.mp4" -o output.mp4

Read the final video URL from content.video_url in the task status response, not from the create response.

Notes and limits

  • Billing is per generated second and settles when the task reaches a terminal state. For Grok, pricing varies by resolution, and image-guided generation may add an image fee. Video billing does not behave like standard text-token billing, so token-count fields may be empty or not useful for billing even when Credits change.
  • A task is rejected at create time if your team balance is too low.
  • The number of in-flight, or pending, tasks per user is capped. Exceeding the cap returns 429.
  • Task reads are owner-scoped: you can only poll a task created by the same authorized account, team, or API key. Cross-owner reads return 403 media_resource_access_denied.
  • List routes are disabled. GET /v1/videos/generations without a task id is not supported.

Troubleshooting

SymptomLikely causeWhat to do
400 invalid_request (requires image.url)You sent grok-imagine-video-1.5-preview without an image.urlAdd image.url, or use grok-imagine-video for text-only generation.
402 grok_video_balance_too_lowThe scoped team does not have enough available credits at create timeRecharge on Credits and retry.
403 grok_video_team_requiredThe key is not scoped to a teamUse a team-scoped API key.
403 media_resource_access_deniedThe task belongs to another owner contextReuse the same account, team, or API key that created the task.
429 grok_video_too_many_pending_tasksToo many of your Grok video tasks are still runningWait for active tasks to finish before creating more.
424 with an error bodyThe upstream video provider failed or timed outTransient provider failure — retry after a short wait. The body keeps the upstream error and upstream_status.

See also

Last updated on