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
/v1surface. - Grok video requests are asynchronous. A successful create request returns a task
id; the video is only ready after the taskstatusbecomessucceeded.
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:
| Model | Best for |
|---|---|
grok-imagine-video | Standard text-to-video generation. |
grok-imagine-video-1.5-preview | Image-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
- 1Create a video task with
POST /videos/generations. - 2Save the returned task
id. - 3Poll
GET /videos/generations/{task_id}until the task reaches a terminal state. - 4When
statusbecomessucceeded, download the video fromcontent.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 -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:
{
"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:
{
"model": "grok-imagine-video-1.5-preview",
"prompt": "Pan slowly across the scene.",
"resolution": "720p",
"image": {
"url": "https://your-host.example.com/start.png"
}
}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 "https://inference-api-pre-d80ca3.worldrouter.ai/v1/videos/generations/task_123" \
-H "Authorization: Bearer your_api_key"Typical status response:
{
"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:
queuedrunningsucceededfailedcancelledexpired
Download the output
Only download the result after the task status becomes succeeded:
curl -L "https://media.example.com/output.mp4" -o output.mp4Read 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/generationswithout a task id is not supported.
Troubleshooting
| Symptom | Likely cause | What to do |
|---|---|---|
400 invalid_request (requires image.url) | You sent grok-imagine-video-1.5-preview without an image.url | Add image.url, or use grok-imagine-video for text-only generation. |
402 grok_video_balance_too_low | The scoped team does not have enough available credits at create time | Recharge on Credits and retry. |
403 grok_video_team_required | The key is not scoped to a team | Use a team-scoped API key. |
403 media_resource_access_denied | The task belongs to another owner context | Reuse the same account, team, or API key that created the task. |
429 grok_video_too_many_pending_tasks | Too many of your Grok video tasks are still running | Wait for active tasks to finish before creating more. |
424 with an error body | The upstream video provider failed or timed out | Transient provider failure — retry after a short wait. The body keeps the upstream error and upstream_status. |
See also
- Kling video guide: the Kling async video API.
- Seedance video guide: the Seedance async task API.
- Quickstart: API key and base URL setup.
- Models: current model catalog and pricing.
- API reference: chat-completions docs for text models.