Inference API

Videos

View as Markdown

Video generation

/v1/videos/generations

Generate a video from a text prompt and optionally an image. This is an asynchronous operation that returns a request_id for polling.

Request Body

Response Body

request_idstring

A unique request ID to poll for the result.

Code Examples

**Response example:**


Example
curl -s https://api.x.ai/v1/videos/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -d '{
    "model": "grok-imagine-video-1.5",
    "prompt": "A serene lake at sunrise with mist rolling over the water"
  }'
Exampletext

text

{
  "request_id": "41eb9a5f-cbd4-9f21-8d59-79005f1e61b7"
}

Video edit

/v1/videos/edits

Edit a video based on a prompt. This is an asynchronous operation that returns a request_id for polling.

Request Body

promptstring

Prompt for video editing.

videoobject

Video input for editing and extension requests. Accepts a public URL, a base64-encoded data URL, or a file_id from the xAI Files API.

Response Body

request_idstring

A unique request ID to poll for the result.

Code Examples

**Response example:**


Example
curl -s https://api.x.ai/v1/videos/edits \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -d "{
    \"model\": \"grok-imagine-video\",
    \"prompt\": \"Give the woman a silver necklace\",
    \"video\": {
      \"url\": \"$VIDEO_URL\"
    }
  }"
Exampletext

text

{
  "request_id": "69ad8ab2-3459-9c92-a372-cb3dcc3533b2"
}

Video extension

/v1/videos/extensions

Extend a video by generating continuation content. This is an asynchronous operation that returns a request_id for polling.

Request Body

promptstring

Prompt describing what should happen next in the video.

videoobject

Video input for editing and extension requests. Accepts a public URL, a base64-encoded data URL, or a file_id from the xAI Files API.

Response Body

request_idstring

A unique request ID to poll for the result.

Exampletext

text

{
  "prompt": "The camera slowly zooms out to reveal the city skyline",
  "video": {
    "url": "https://example.com/video.mp4"
  },
  "model": "grok-imagine-video",
  "duration": 6
}
Exampletext

text

{
  "request_id": "a3d1008e-4544-40d4-d075-11527e794e4a"
}

Get video generation results

/v1/videos/{request_id}

Get the result of a deferred video generation request.

Path Parameters

request_idstring

The deferred request id returned by a previous video generation request.

Response Body

statusstring

Status of the video generation: "done" when the video is ready.

Code Examples

**Response example:**

Example
curl -s "https://api.x.ai/v1/videos/$VIDEO_REQUEST_ID" \
  -H "Authorization: Bearer $XAI_API_KEY"
Exampletext

text

{
  "status": "done",
  "video": {
    "url": "https://vidgen.x.ai/xai-vidgen-bucket/xai-video-cb3a83ec-322f-4318-990d-166bab11d328.mp4",
    "duration": 1,
    "respect_moderation": true
  },
  "model": "grok-imagine-video",
  "usage": {
    "cost_in_usd_ticks": 500000000
  },
  "progress": 100
}

Last updated:April 13, 2026