Video Generation API

Generate short AI videos with xAI's Grok Imagine. Text or image prompt in, MP4 URL out.

Endpoint

POST https://blockrun.ai/api/v1/videos/generations

Request

{
  "model": "xai/grok-imagine-video",
  "prompt": "a red apple slowly spinning on a wooden table, daylight",
  "image_url": "https://example.com/seed.jpg"
}

Parameters

ParameterTypeRequiredDescription
modelstringYesVideo model ID (see below)
promptstringYesText description of the video to generate
image_urlstringNoOptional seed image URL for image-to-video
duration_secondsintegerNoDuration billed for (defaults to model's default)

Available Models

Model IDProviderOutputBilling
xai/grok-imagine-videoxAI8s MP4$0.050/second (default 8s = $0.42 with margin)

xAI's Grok Imagine Video accepts text and/or image input and returns an 8-second MP4 clip.

Response

{
  "created": 1776443975,
  "model": "xai/grok-imagine-video",
  "data": [
    {
      "url": "https://blockrun.ai/api/media/media/videos/2026/04/17/<id>.mp4",
      "source_url": "https://vidgen.x.ai/xai-vidgen-bucket/xai-video-<id>.mp4",
      "duration_seconds": 8,
      "request_id": "<xai-request-id>",
      "backed_up": true
    }
  ]
}

Response Fields

FieldTypeDescription
createdintegerUnix timestamp
data[].urlstringPermanent URL. When GCS backup succeeds, this is a blockrun-hosted proxy URL; otherwise the upstream URL
data[].source_urlstringOriginal upstream URL from xAI (temporary — may expire)
data[].duration_secondsintegerDuration of the generated video
data[].request_idstringxAI request ID for debugging / deduplication
data[].backed_upbooleantrue when the video was mirrored to BlockRun's GCS bucket

Why both url and source_url? xAI's vidgen.x.ai URLs are temporary. BlockRun mirrors each generated video to Google Cloud Storage and returns the permanent proxy URL as url. source_url is kept for debugging. If the backup step fails, url falls back to the upstream URL and backed_up is false.

Timing

Video generation is asynchronous upstream. This endpoint handles the full polling loop so you only need to make a single request.

PhaseTypical latency
Request → xAI job submitted~1s
Polling until video ready15–60s (typically under 30s)
GCS backup + settle payment1–3s
Total~20–60s

The connection stays open until the video is ready. Make sure your HTTP client allows at least 180s.

Examples

Via ClawRouter (recommended for local use)

ClawRouter handles x402 payments automatically.

curl -X POST http://localhost:8402/v1/videos/generations \
  -H "Content-Type: application/json" \
  -d '{
    "model": "xai/grok-imagine-video",
    "prompt": "a neon-lit cyberpunk street at night, camera slowly dollying forward"
  }'

Direct API (cURL)

curl -X POST https://blockrun.ai/api/v1/videos/generations \
  -H "Content-Type: application/json" \
  -H "X-Payment: $PAYMENT_HEADER" \
  -d '{
    "model": "xai/grok-imagine-video",
    "prompt": "a hummingbird hovering in front of a red flower, ultra slow motion"
  }'

Image-to-video

curl -X POST http://localhost:8402/v1/videos/generations \
  -H "Content-Type: application/json" \
  -d '{
    "model": "xai/grok-imagine-video",
    "prompt": "the subject turns its head and smiles",
    "image_url": "https://example.com/portrait.jpg"
  }'

Pricing

ModelUnitPriceMarginBilled (8s)
xai/grok-imagine-videoper second$0.0505%$0.42

Error Codes

CodeDescription
400Invalid request (bad prompt, parameters, or duration_seconds above model max)
402Payment required or payment verification/settlement failed
403Content policy violation
429Rate limit exceeded (xAI caps at 60 RPM)
500Server error
504Video generation timed out (xAI job did not complete within 180s)

Links