Skip to content

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 ​

MethodFull Endpoint PathPurpose
POST/v1/videos/generationsCreate an asynchronous video task (HTTP 202 Accepted)
GET/v1/tasks/{id}Query task progress and status by task ID
GET/v1/tasks/{id}/contentDownload private MP4 after success (HTTP 307 Redirect)

Before you start

  1. Use your Workspace model-routing API Key (sk-tokenlio-...).
  2. Verify that grok-imagine-video is enabled in your Model Marketplace.
  3. Video creation is asynchronous (HTTP 202 Accepted); query task progress until status=succeeded before downloading.

Key capabilities and specifications ​

CapabilitySpecificationsDetails & recommendations
Text-to-video1–15 integer seconds; 480p / 720pExplicit integer duration is required; 6s is recommended for initial validation.
Image reference1–50 HTTPS images (order preserved)Guide scene composition, character design, and style consistency.
Video editingExclusive 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:3Defaults to auto. size specifies geometric aspect ratio, not pixel dimensions.
Delivery & formatMP4 output; no last frameSecure private storage delivery with short-lived signed download URLs.

End-to-end quick start ​

bash
# 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.mp4

Request parameter specification ​

FieldTypeGeneration ruleEditing rule (Base only)Description & constraints
modelstringMust be grok-imagine-videoMust be grok-imagine-videoExact published model ID. No unapproved suffixes or uppercase variants.
promptstringRequired nonblank stringRequired nonblank stringScene description or styling directive; up to 8,000 Unicode characters.
operationstringOptional generate (default)Required editOperation discriminator. Distinct idempotency fingerprint from omitted operation.
durationintegerRequired integer 1–15Must be omittedOutput duration in seconds. For editing, server measures source duration.
resolutionstring480p / 720p (default 480p)Must be omittedOutput resolution tier. Editing defaults to 720p re-rendering basis.
sizestringOptional (default auto)Must be omittedAspect ratio. Editing retains the source video geometry.
image_urlsstring[]Optional 1–50 URLsMust be omittedOrdered reference images. Omit rather than passing empty [].
video_urlsstring[]Must be omittedExactly 1 source URLDirect 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, or output_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:

json
{
  "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:

json
{
  "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:

json
{
  "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 ​

  1. 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.
  2. Deduplication: Duplicate URLs within a single request are rejected. The 50-image ceiling is a platform safety limit, not a quality guarantee.
  3. Source video validation: Source videos are safely downloaded and probed. Non-standard MP4 containers, corrupted streams, or inaccessible URLs trigger VIDEO_ASSET_INVALID.
  4. 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 → succeeded or failed.
  • Download: When status=succeeded, fetch GET /v1/tasks/{id}/content to obtain an HTTP 307 redirect to the private MP4 link.
  • Idempotency: Use the optional Idempotency-Key header (1–128 printable ASCII) to prevent duplicate charges during network timeouts. Failed or timed-out tasks return TASK_TIMEOUT in error.code.

Error codes and troubleshooting ​

HTTP StatusError CodeProbable Cause & Resolution
400VIDEO_REQUEST_INVALIDMissing prompt, duration omitted or outside 1–15, invalid aspect ratio, or mixed generation/editing fields.
400VIDEO_ASSET_INVALIDAsset URL unreachable, redirect detected, corrupt image, or non-MP4 video container.
401INVALID_API_KEYAPI key is missing, malformed, revoked, or IP-restricted.
402INSUFFICIENT_BALANCEInsufficient Workspace funds. Top up your balance in the console.
404MEDIA_TASK_NOT_FOUNDTask ID not found or unauthorized cross-workspace access attempt.
409 VIDEO_PRICE_CHANGEDReview current catalog terms before deciding whether to create again.
409VIDEO_IDEMPOTENCY_CONFLICTSame Idempotency-Key reused with altered payload.
503VIDEO_SERVICE_UNAVAILABLEThe service is temporarily unavailable. Check status code TASK_TIMEOUT on failure.

Shared video task guide

Access leading AI models through one unified API