Grok Imagine Video
xAI · 1–15s · 480p / 720p · Image references · Video editing · Actual-cost billing
Grok Imagine Video is an advanced video generation model by xAI featuring realistic motion physics, lighting fidelity, and prompt adherence. In addition to high-quality text-to-video and reference-guided generation, it exclusively supports single-video stylistic re-rendering and color grading through the unified Tokenlio asynchronous video engine.
API Endpoints
| Method | Full Endpoint Path | Purpose |
|---|---|---|
| POST | /v1/videos/generations | Create an asynchronous video task (HTTP 202 Accepted) |
| GET | /v1/tasks/{id} | Query task progress and status by task ID |
| GET | /v1/tasks/{id}/content | Download private MP4 after success (HTTP 307 Redirect) |
Before you start
- Use your Workspace model-routing API Key (
sk-tokenlio-...). - Verify that
grok-imagine-videois enabled in your Model Marketplace. - Video creation is asynchronous (HTTP 202 Accepted); query task progress until
status=succeededbefore downloading.
Key capabilities and specifications
| Capability | Specifications | Details & recommendations |
|---|---|---|
| Text-to-video | 1–15 integer seconds; 480p / 720p | Explicit integer duration is required; 6s is recommended for initial validation. |
| Image reference | 1–50 HTTPS images (order preserved) | Guide scene composition, character design, and style consistency. |
| Video editing | Exclusive to Base (operation: edit) | Restyle or color-grade an existing video; generation fields are strictly prohibited. |
Aspect ratio (size) | auto, 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3 | Defaults to auto. size specifies geometric aspect ratio, not pixel dimensions. |
| Delivery & format | MP4 output; no last frame | Secure private storage delivery with short-lived signed download URLs. |
End-to-end quick start
# 1. Submit a video task (returns HTTP 202 with task ID)
BASE_URL='https://api.tokenlio.ai'
curl "$BASE_URL/v1/videos/generations" \
-H "Authorization: Bearer $TOKENLIO_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"model":"grok-imagine-video","prompt":"A quiet landscape at sunrise","duration":6,"resolution":"480p","size":"16:9"}'
# Example Response: {"id":"dfc68868-d388-4d83-a173-d44e47a8bec7","model":"grok-imagine-video","status":"queued","assets":[]}
# 2. Poll task progress every 5–15 seconds
TASK_ID='YOUR_TASK_ID'
curl "$BASE_URL/v1/tasks/$TASK_ID" \
-H "Authorization: Bearer $TOKENLIO_API_KEY"
# 3. Download the result MP4 video
curl --location "$BASE_URL/v1/tasks/$TASK_ID/content" \
-H "Authorization: Bearer $TOKENLIO_API_KEY" -o result.mp4Request parameter specification
| Field | Type | Generation rule | Editing rule (Base only) | Description & constraints |
|---|---|---|---|---|
model | string | Must be grok-imagine-video | Must be grok-imagine-video | Exact published model ID. No unapproved suffixes or uppercase variants. |
prompt | string | Required nonblank string | Required nonblank string | Scene description or styling directive; up to 8,000 Unicode characters. |
operation | string | Optional generate (default) | Required edit | Operation discriminator. Distinct idempotency fingerprint from omitted operation. |
duration | integer | Required integer 1–15 | Must be omitted | Output duration in seconds. For editing, server measures source duration. |
resolution | string | 480p / 720p (default 480p) | Must be omitted | Output resolution tier. Editing defaults to 720p re-rendering basis. |
size | string | Optional (default auto) | Must be omitted | Aspect ratio. Editing retains the source video geometry. |
image_urls | string[] | Optional 1–50 URLs | Must be omitted | Ordered reference images. Omit rather than passing empty []. |
video_urls | string[] | Must be omitted | Exactly 1 source URL | Direct HTTPS link to the source video to edit. |
Strict parameter mutual exclusion
- Forbidden controls: Do not send
video,aspect_ratio,generate_audio,seed,return_last_frame, oroutput_format. - Editing exclusivity: When
operation: edit, all generation controls (duration,resolution,size,image_urls) must be omitted, even if 0, empty, or null. - Payload limit: The entire JSON payload must not exceed 64 KiB.
Typical usage scenarios
Scenario 1: Single image reference
Guide camera motion or visual style from an image using explicit operation: generate:
{
"model": "grok-imagine-video",
"prompt": "A quiet landscape at sunrise",
"duration": 6,
"resolution": "480p",
"size": "16:9",
"image_urls": [
"https://cdn.example.com/reference-a.png"
],
"operation": "generate"
}Scenario 2: Multiple image references
Combine multiple reference images while preserving array ordering:
{
"model": "grok-imagine-video",
"prompt": "A quiet landscape at sunrise",
"duration": 6,
"resolution": "480p",
"size": "16:9",
"image_urls": [
"https://cdn.example.com/reference-a.png",
"https://cdn.example.com/reference-b.png"
]
}Scenario 3: Single-video style editing (Base exclusive)
Pass exactly one source video URL and styling instructions without generation fields:
{
"model": "grok-imagine-video",
"operation": "edit",
"prompt": "Give the scene warm sunset lighting",
"video_urls": [
"https://cdn.example.com/source.mp4"
]
}Asset URL and network transmission rules
- Public HTTPS direct access: All image and video URLs must be publicly accessible via standard HTTPS/443 without redirects, credentials, private IPs, or URL fragments.
- Deduplication: Duplicate URLs within a single request are rejected. The 50-image ceiling is a platform safety limit, not a quality guarantee.
- Source video validation: Source videos are safely downloaded and probed. Non-standard MP4 containers, corrupted streams, or inaccessible URLs trigger
VIDEO_ASSET_INVALID. - Content stability: Keep URLs immutable; server measurements rely on byte-level consistency.
Billing and reference rates
Reference rates are shown in the console; they are not a pre-charge or a spending cap. Final actual charges appear as charged_amount in task/call records after successful delivery and settlement. Failed, timed-out (TASK_TIMEOUT) or undelivered tasks are not charged, and polling/downloads are not new generation calls.
max_charge_amount is not accepted for actual-cost models. expected_pricing_revision is optional: send it only when you already hold a valid pricing version. Review current catalog terms rather than blindly resending a changed-price request.
video-reference-pricing/v2 · USD
Lifecycle, polling and download
- Acceptance: A successful submission returns HTTP 202 Accepted with a task
id. - Polling: Poll
GET /v1/tasks/{id}every 5–15 seconds. Status transitions:queued→processing→succeededorfailed. - Download: When
status=succeeded, fetchGET /v1/tasks/{id}/contentto obtain an HTTP 307 redirect to the private MP4 link. - Idempotency: Use the optional
Idempotency-Keyheader (1–128 printable ASCII) to prevent duplicate charges during network timeouts. Failed or timed-out tasks returnTASK_TIMEOUTinerror.code.
Error codes and troubleshooting
| HTTP Status | Error Code | Probable Cause & Resolution |
|---|---|---|
| 400 | VIDEO_REQUEST_INVALID | Missing prompt, duration omitted or outside 1–15, invalid aspect ratio, or mixed generation/editing fields. |
| 400 | VIDEO_ASSET_INVALID | Asset URL unreachable, redirect detected, corrupt image, or non-MP4 video container. |
| 401 | INVALID_API_KEY | API key is missing, malformed, revoked, or IP-restricted. |
| 402 | INSUFFICIENT_BALANCE | Insufficient Workspace funds. Top up your balance in the console. |
| 404 | MEDIA_TASK_NOT_FOUND | Task ID not found or unauthorized cross-workspace access attempt. |
409 VIDEO_PRICE_CHANGED | Review current catalog terms before deciding whether to create again. | |
| 409 | VIDEO_IDEMPOTENCY_CONFLICT | Same Idempotency-Key reused with altered payload. |
| 503 | VIDEO_SERVICE_UNAVAILABLE | The service is temporarily unavailable. Check status code TASK_TIMEOUT on failure. |
