SpyBara
Go Premium

Documentation 2026-11-12 22:57 UTC to 2026-11-13 23:57 UTC

19 files changed +63 −64. View all changes and history on the product overview
2026
Tue 24 23:59 Mon 23 23:59 Fri 20 23:59 Thu 19 22:57 Wed 18 23:57 Tue 17 23:59 Mon 16 23:59 Sun 15 22:59 Fri 13 23:57 Thu 12 22:57 Wed 11 23:00 Tue 10 23:57 Mon 9 23:00 Sun 8 23:57 Sat 7 22:59 Fri 6 23:59 Thu 5 23:58 Wed 4 23:01 Tue 3 23:00 Mon 2 23:57 Sun 1 23:02
Details

6 6 

7> [!TIP]7> [!TIP]

8>8>

9> Text watermarking is off by default. Team admins can turn it on per model in the SpaceXSI Console's team settings; see [How to enable text watermarking](#how-to-enable-text-watermarking). Audio from the voice APIs is watermarked in some regions, when your team turns it on, and when you ask for it; see [Audio watermarking](#audio-watermarking).9> Text watermarking is off by default. Team admins can turn it on per model in the SpaceXSI Console's team settings; see [How to enable text watermarking](#how-to-enable-text-watermarking). Audio from the voice APIs is watermarked by default. Team admins can opt a voice model out, except where the user's location requires the watermark; see [Audio watermarking](#audio-watermarking).

10 10 

11## Which outputs are watermarked11## Which outputs are watermarked

12 12 


121 121 

122## Audio watermarking122## Audio watermarking

123 123 

124Audio from the voice APIs can also include an invisible watermark. This applies to [Text to Speech](/developers/model-capabilities/audio/text-to-speech) and [Speech to Speech](/developers/model-capabilities/audio/speech-to-speech), including speech in [custom voices](/developers/model-capabilities/audio/custom-voices).124Audio from the voice APIs includes an invisible watermark by default. This applies to [Text to Speech](/developers/model-capabilities/audio/text-to-speech) and [Speech to Speech](/developers/model-capabilities/audio/speech-to-speech), including speech in [custom voices](/developers/model-capabilities/audio/custom-voices).

125 125 

126The watermark is [AudioSeal](https://github.com/facebookresearch/audioseal). It is added to the audio before it is encoded, so every output format includes it, and it can't be heard.126The watermark is [AudioSeal](https://github.com/facebookresearch/audioseal). It is added to the audio before it is encoded, so every output format includes it, and it can't be heard.

127 127 

128### Which audio is watermarked128### Which audio is watermarked

129 129 

130Audio is watermarked when:130All audio is watermarked unless your team opted the voice model out in the SpaceXSI Console. See [Opt a voice model out](#opt-a-voice-model-out).

131 131 

132* The end user is in the EU, the EEA, or California. The location comes from the IP address of the request.132Even for a model your team opted out, audio is watermarked when:

133* Your team turned watermarking on for the voice model in the SpaceXSI Console. See [Turn on audio watermarking for your team](#turn-on-audio-watermarking-for-your-team).

134* The request asks for a watermark. See [How to enable audio watermarking](#how-to-enable-audio-watermarking).

135 133 

136If none of these apply, the audio is not watermarked.134* The end user is in the EU, the EEA, or California. The location comes from the IP address of the request.

135* The request asks for a watermark. See [Request a watermark](#request-a-watermark).

137 136 

138### Checking whether audio was watermarked137### Checking whether audio was watermarked

139 138 

140Read the `x-watermark` header on the response, as with text. `x-watermark: true` means the audio was watermarked, and `x-watermark: false` means it was not. For WebSocket connections, the header is on the response that opens the connection.139Read the `x-watermark` header on the response, as with text. `x-watermark: true` means the audio was watermarked, and `x-watermark: false` means it was not. For WebSocket connections, the header is on the response that opens the connection.

141 140 

142### How to enable audio watermarking141### Request a watermark

143 142 

144Add the `x-watermark: true` header to your request. If your WebSocket client can't set headers, add `watermark=true` to the URL instead.143If your team opted a voice model out, you can still watermark a single request. Add the `x-watermark: true` header to it. If your WebSocket client can't set headers, add `watermark=true` to the URL instead.

145 144 

146```bash customLanguage="bash"145```bash customLanguage="bash"

147curl -X POST https://api.x.ai/v1/tts \146curl -X POST https://api.x.ai/v1/tts \


186 185 

187`x-watermark: false` doesn't remove a watermark that is required by the user's location. Any value other than `true` or `false` returns a `400` error.186`x-watermark: false` doesn't remove a watermark that is required by the user's location. Any value other than `true` or `false` returns a `400` error.

188 187 

189### Turn on audio watermarking for your team188### Opt a voice model out

190 189 

191Team admins can watermark all audio from a voice model, for every API key on the team, without changing requests.190Team admins can stop watermarking audio from a voice model, for every API key on the team.

192 191 

1931. Open the [Team settings page](https://console.x.ai/team/default/settings/team?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-watermarking\&utm_content=team-settings-voice) and select the settings icon on the **Model output watermarking** row.1921. Open the [Team settings page](https://console.x.ai/team/default/settings/team?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-watermarking\&utm_content=team-settings-voice) and select the settings icon on the **Model output watermarking** row.

1942. Under **Voice models**, select the checkbox for each model you want to watermark.1932. Under **Voice models**, clear the checkbox for each model you want to opt out.

1953. Select **Save**.1943. Select **Save**, then confirm in the **Opt out of watermarking?** dialog.

196 195 

197Changes apply to new requests within 5 minutes. Turning a voice model off doesn't ask for confirmation, and audio stays watermarked where the user's location requires it.196Changes apply to new requests within 5 minutes, and the opt-out is recorded in your team's audit log. Audio stays watermarked where the user's location requires it. To watermark a model again, select its checkbox and save.

198 197 

199## FAQ198## FAQ

200 199 

201### Do I need to change my code?200### Do I need to change my code?

202 201 

203No. Text watermarking is turned on in the Console, and audio is watermarked where required without any changes. To watermark other audio, turn it on for your team in the Console or send the `x-watermark: true` header.202No. Audio is watermarked by default, and text watermarking is turned on in the Console.

204 203 

205### Does the setting apply to all of my API keys?204### Does the setting apply to all of my API keys?

206 205 


214 213 

215### Can I turn off audio watermarking?214### Can I turn off audio watermarking?

216 215 

217Audio is only watermarked in the cases listed in [Which audio is watermarked](#which-audio-is-watermarked). When the end user is in the EU, the EEA, or California, the watermark can't be turned off.216Team admins can opt a voice model out in the Console; see [Opt a voice model out](#opt-a-voice-model-out). When the end user is in the EU, the EEA, or California, or the request sends `x-watermark: true`, audio is still watermarked.

218 217 

219### Does watermarking affect quality or speed?218### Does watermarking affect quality or speed?

220 219 

Details

15 15 

16> [!TIP]16> [!TIP]

17>17>

18> Generating images or videos with the [Imagine API](/developers/model-capabilities/imagine)? You18> Generating images or videos with the [image & video API](/developers/model-capabilities/imagine)? You

19> can create a public URL **in the same request that produces the asset** via19> can create a public URL **in the same request that produces the asset** via

20> `storage_options.public_url`. See [Imagine → Files API20> `storage_options.public_url`. See [Files API integration for image & video

21> Integration](/developers/model-capabilities/imagine/files).21> requests](/developers/model-capabilities/imagine/files).

22 22 

23## Quick Start23## Quick Start

24 24 


64>64>

65> Public URLs can only be created for files that **already exist** in your Files API storage. You65> Public URLs can only be created for files that **already exist** in your Files API storage. You

66> cannot create a public URL during upload — upload the file first, then call `create_public_url`66> cannot create a public URL during upload — upload the file first, then call `create_public_url`

67> (or use `storage_options.public_url` on an Imagine request).67> (or use `storage_options.public_url` on an image or video request).

68 68 

69## Expiry Behaviour69## Expiry Behaviour

70 70 


246## Related246## Related

247 247 

248* [Managing Files](/developers/files/managing-files) — Upload, list, retrieve, and delete files.248* [Managing Files](/developers/files/managing-files) — Upload, list, retrieve, and delete files.

249* [Imagine → Files API Integration](/developers/model-capabilities/imagine/files) — Reference stored files as Imagine inputs, persist generated assets, and create public URLs in a single request.249* [Files API integration for image & video requests](/developers/model-capabilities/imagine/files) — Reference stored files as image & video inputs, persist generated assets, and create public URLs in a single request.

250* [Files API Reference](/developers/rest-api-reference/files) — Full REST endpoint documentation.250* [Files API Reference](/developers/rest-api-reference/files) — Full REST endpoint documentation.

Details

68 68 

69* A **public URL** pointing to an image69* A **public URL** pointing to an image

70* A **base64-encoded data URI** (e.g., `data:image/jpeg;base64,...`)70* A **base64-encoded data URI** (e.g., `data:image/jpeg;base64,...`)

71* A **`file_id`** from the [Files API](/developers/files) — see [Imagine → Files API Integration](/developers/model-capabilities/imagine/files/inputs)71* A **`file_id`** from the [Files API](/developers/files) — see [Files API integration for image & video requests](/developers/model-capabilities/imagine/files/inputs)

72 72 

73## Multi-turn editing73## Multi-turn editing

74 74 


84* [Multi-Image Editing](/developers/model-capabilities/images/multi-image-editing) — Edit with multiple source images84* [Multi-Image Editing](/developers/model-capabilities/images/multi-image-editing) — Edit with multiple source images

85* [Image Prompting Guide](/developers/model-capabilities/images/prompting-guide) — When to edit, and how to phrase an edit prompt85* [Image Prompting Guide](/developers/model-capabilities/images/prompting-guide) — When to edit, and how to phrase an edit prompt

86* [API Reference](/developers/rest-api-reference) — Full endpoint documentation86* [API Reference](/developers/rest-api-reference) — Full endpoint documentation

87* [Imagine API Landing Page](https://x.ai/api/imagine) — Showcase of the Imagine API in action87* [Image & Video API Landing Page](https://x.ai/api/imagine) — Showcase of the image & video API in action

Details

2 2 

3# Image Generation3# Image Generation

4 4 

5Generate images from text prompts with Grok Imagine models. The API supports batch generation of multiple images, and control over aspect ratio, resolution, and quality.5Generate images from text prompts with Grok image models. The API supports batch generation of multiple images, and control over aspect ratio, resolution, and quality.

6 6 

7## Quick Start7## Quick Start

8 8 


590* [Image Generation Tool](/developers/tools/image-generation) — Let Grok generate and edit images inside a conversation590* [Image Generation Tool](/developers/tools/image-generation) — Let Grok generate and edit images inside a conversation

591* [Video Generation](/developers/model-capabilities/video/generation) — Generate videos from text prompts591* [Video Generation](/developers/model-capabilities/video/generation) — Generate videos from text prompts

592* [API Reference](/developers/rest-api-reference) — Full endpoint documentation592* [API Reference](/developers/rest-api-reference) — Full endpoint documentation

593* [Imagine API Landing Page](https://x.ai/api/imagine) — Showcase of the Imagine API in action593* [Image & Video API Landing Page](https://x.ai/api/imagine) — Showcase of the image & video API in action

Details

4 4 

5Use up to five source images for a single image edit. You can specify images in the order they are sent in the request. By default, the output aspect ratio follows the first input image. You can override this by setting the `aspect_ratio` parameter to a specific ratio, such as `"1:1"` or `"16:9"`.5Use up to five source images for a single image edit. You can specify images in the order they are sent in the request. By default, the output aspect ratio follows the first input image. You can override this by setting the `aspect_ratio` parameter to a specific ratio, such as `"1:1"` or `"16:9"`.

6 6 

7Each source image can be a public URL, a base64-encoded data URI, or a `file_id` from the [Files API](/developers/files) — and you can mix kinds within a single request. See [Imagine → Files API Integration](/developers/model-capabilities/imagine/files/inputs) for `file_id` details and examples.7Each source image can be a public URL, a base64-encoded data URI, or a `file_id` from the [Files API](/developers/files) — and you can mix kinds within a single request. See [Files API integration for image & video requests](/developers/model-capabilities/imagine/files/inputs) for `file_id` details and examples.

8 8 

9## Related9## Related

10 10 

11* [Image Generation](/developers/model-capabilities/images/generation) — Generate images from text prompts11* [Image Generation](/developers/model-capabilities/images/generation) — Generate images from text prompts

12* [Image Editing](/developers/model-capabilities/images/editing) — Edit a source image with natural language12* [Image Editing](/developers/model-capabilities/images/editing) — Edit a source image with natural language

13* [API Reference](/developers/rest-api-reference) — Full endpoint documentation13* [API Reference](/developers/rest-api-reference) — Full endpoint documentation

14* [Imagine API Landing Page](https://x.ai/api/imagine) — Showcase of the Imagine API in action14* [Image & Video API Landing Page](https://x.ai/api/imagine) — Showcase of the image & video API in action

Details

1#### Imagine API1#### Image API

2 2 

3# Image Prompting Guide3# Image Prompting Guide

4 4 


42 }'42 }'

43```43```

44 44 

45Lock `aspect_ratio` across a series so the images sit together; `3:2` suits most photographs. [`quality`](/developers/model-capabilities/images/generation#quality) accepts `low`, `medium`, or `auto`, and `auto` currently serves `low` on generation and `medium` on edit. Pin `medium` and `2k` when fine detail has to be recognizable. Generated URLs are temporary, so request `b64_json` when you plan to keep the file, or store it with [Imagine outputs](/developers/model-capabilities/imagine/files/outputs).45Lock `aspect_ratio` across a series so the images sit together; `3:2` suits most photographs. [`quality`](/developers/model-capabilities/images/generation#quality) accepts `low`, `medium`, or `auto`, and `auto` currently serves `low` on generation and `medium` on edit. Pin `medium` and `2k` when fine detail has to be recognizable. Generated URLs are temporary, so request `b64_json` when you plan to keep the file, or store it with [Files API outputs](/developers/model-capabilities/imagine/files/outputs).

46 46 

47## Write the subject first47## Write the subject first

48 48 

Details

1#### Model Capabilities1#### Model Capabilities

2 2 

3# Imagine Overview3# Image & Video Overview

4 4 

5The Imagine API lets you generate and edit images and videos with Grok Imagine models. Use it for image generation, image editing with up to 5 reference images, video generation from text or still images, video editing, and more.5The image & video API lets you generate and edit images and videos with Grok image & video models. Use it for image generation, image editing with up to 5 reference images, video generation from text or still images, video editing, and more.

6 6 

7## Pricing7## Pricing

8 8 


10 10 

11## Image Generation11## Image Generation

12 12 

13Generate new images from text prompts with Grok Imagine models. Configure output count (up to 10 images per request), aspect ratio, resolution, and response format.13Generate new images from text prompts with Grok image models. Configure output count (up to 10 images per request), aspect ratio, resolution, and response format.

14 14 

15```javascript customLanguage="javascriptAISDK"15```javascript customLanguage="javascriptAISDK"

16import { xai } from "@ai-sdk/xai";16import { xai } from "@ai-sdk/xai";


65 65 

66## Image Editing66## Image Editing

67 67 

68Edit a source image with natural language. Provide a public image URL or base64-encoded data URI, then describe the change you want Grok Imagine to apply. Multi-image editing supports up to 5 source images in a single request for combining subjects, transferring styles, and composing scenes.68Edit a source image with natural language. Provide a public image URL or base64-encoded data URI, then describe the change you want the model to apply. Multi-image editing supports up to 5 source images in a single request for combining subjects, transferring styles, and composing scenes.

69 69 

70```javascript customLanguage="javascriptAISDK"70```javascript customLanguage="javascriptAISDK"

71import { xai } from "@ai-sdk/xai";71import { xai } from "@ai-sdk/xai";


188 188 

189## More Capabilities189## More Capabilities

190 190 

191Beyond the top use cases above, the Imagine API supports several additional workflows. The [Video Overview](/developers/model-capabilities/video/overview) compares the video models and shows each mode with real inputs and outputs.191Beyond the top use cases above, the image & video API supports several additional workflows. The [Video Overview](/developers/model-capabilities/video/overview) compares the video models and shows each mode with real inputs and outputs.

192 192 

193* **[Multi-Image Editing](/developers/model-capabilities/images/multi-image-editing)** — Combine up to 5 source images in a single edit for compositing subjects, transferring styles, and building scenes from multiple references.193* **[Multi-Image Editing](/developers/model-capabilities/images/multi-image-editing)** — Combine up to 5 source images in a single edit for compositing subjects, transferring styles, and building scenes from multiple references.

194* **[Video Generation](/developers/model-capabilities/video/generation)** — Generate videos from text prompts with configurable duration (up to 15s), aspect ratio, and resolution.194* **[Video Generation](/developers/model-capabilities/video/generation)** — Generate videos from text prompts with configurable duration (up to 15s), aspect ratio, and resolution.

195* **[Video Editing](/developers/model-capabilities/video/editing)** — Modify an existing video with a text prompt on `grok-imagine-video`.195* **[Video Editing](/developers/model-capabilities/video/editing)** — Modify an existing video with a text prompt on `grok-imagine-video`.

196* **[Reference-to-Video](/developers/model-capabilities/video/reference-to-video)** — Guide a video with up to 14 reference images and 3 voice references on `grok-imagine-video-1.5`, and pin first, last, and mid-video frames.196* **[Reference-to-Video](/developers/model-capabilities/video/reference-to-video)** — Guide a video with up to 14 reference images and 3 voice references on `grok-imagine-video-1.5`, and pin first, last, and mid-video frames.

197* **[Video Extension](/developers/model-capabilities/video/extension)** — Continue an existing video from its last frame, combining the original and extension into one clip.197* **[Video Extension](/developers/model-capabilities/video/extension)** — Continue an existing video from its last frame, combining the original and extension into one clip.

198* **[Files API Integration](/developers/model-capabilities/imagine/files)** — Reference stored files as Imagine inputs by ID, persist generated assets to the Files API, and optionally create a permanent shareable public URL — all in a single request.198* **[Files API Integration](/developers/model-capabilities/imagine/files)** — Reference stored files as image & video inputs by ID, persist generated assets to the Files API, and optionally create a permanent shareable public URL — all in a single request.

199 199 

200## Enterprise Compliance & Security200## Enterprise Compliance & Security

201 201 

202The Imagine APIs are built for production workloads with strict security and compliance requirements. Generated media is subject to content policy review and is not used for training.202The image & video APIs are built for production workloads with strict security and compliance requirements. Generated media is subject to content policy review and is not used for training.

203 203 

204* **SOC 2 Type II** — Audited controls for security, availability, and confidentiality204* **SOC 2 Type II** — Audited controls for security, availability, and confidentiality

205 205 

Details

2 2 

3# Files API Integration3# Files API Integration

4 4 

5The Imagine API integrates with the [Files API](/developers/files) in two directions:5The image & video API integrates with the [Files API](/developers/files) in two directions:

6 6 

7* **Inputs** — anywhere an Imagine endpoint accepts a public URL or base64-encoded image/video, you can substitute a `file_id` from your Files storage. No need to make the file public or re-upload bytes on every call.7* **Inputs** — anywhere an image or video endpoint accepts a public URL or base64-encoded image/video, you can substitute a `file_id` from your Files storage. No need to make the file public or re-upload bytes on every call.

8* **Outputs** — Imagine can persist the generated asset to your Files storage and optionally create a permanent, shareable public URL for it, alongside the ephemeral generation URL that's always returned by default.8* **Outputs** — image & video requests can persist the generated asset to your Files storage and optionally create a permanent, shareable public URL for it, alongside the ephemeral generation URL that's always returned by default.

9 9 

10By default, Imagine requests return an **ephemeral** URL on `imgen.x.ai` or `vidgen.x.ai` that's only good for fetching the asset shortly after generation. The Files integration lets you both reuse stored inputs and persist outputs in the same request.10By default, image & video requests return an **ephemeral** URL on `imgen.x.ai` or `vidgen.x.ai` that's only good for fetching the asset shortly after generation. The Files integration lets you both reuse stored inputs and persist outputs in the same request.

11 11 

12> [!TIP]12> [!TIP]

13>13>


15 15 

16## Putting it together: an iterative loop16## Putting it together: an iterative loop

17 17 

18The clearest payoff for using inputs and outputs together is chaining Imagine calls without ever leaving the Files API. Reference a stored `file_id` directly from a previous call's `file_output` — no need to download, re-upload, or make the file public.18The clearest payoff for using inputs and outputs together is chaining image & video calls without ever leaving the Files API. Reference a stored `file_id` directly from a previous call's `file_output` — no need to download, re-upload, or make the file public.

19 19 

20```python customLanguage="pythonXAI"20```python customLanguage="pythonXAI"

21import os21import os

Details

2 2 

3# Referencing Files as Input3# Referencing Files as Input

4 4 

5Anywhere an Imagine endpoint accepts a public URL or base64-encoded image/video, you can substitute a `file_id` from your [Files API](/developers/files) storage. The file is fetched server-side from your private storage, so:5Anywhere an image or video endpoint accepts a public URL or base64-encoded image/video, you can substitute a `file_id` from your [Files API](/developers/files) storage. The file is fetched server-side from your private storage, so:

6 6 

7* No bandwidth uploading the same image twice — useful for iterative editing loops.7* No bandwidth uploading the same image twice — useful for iterative editing loops.

8* The original file stays private (no need to make it public to use it as an input).8* The original file stays private (no need to make it public to use it as an input).

9* Works with both uploaded files and assets generated by earlier Imagine calls (via [`storage_options`](/developers/model-capabilities/imagine/files/outputs)).9* Works with both uploaded files and assets generated by earlier image & video calls (via [`storage_options`](/developers/model-capabilities/imagine/files/outputs)).

10 10 

11The referenced file must be the correct content type for the endpoint (images: PNG/JPEG/WebP; videos: MP4) and must be fully uploaded.11The referenced file must be the correct content type for the endpoint (images: PNG/JPEG/WebP; videos: MP4) and must be fully uploaded.

12 12 

Details

2 2 

3# Persisting Generated Output3# Persisting Generated Output

4 4 

5Use `storage_options` on any Imagine request to **persist the generated asset** to your [Files API](/developers/files) storage, where you can retrieve it later through the authenticated Files API. On top of that, set `storage_options.public_url` to additionally generate a **permanent, shareable public URL** for the asset — an unauthenticated link that anyone can open and that stays alive until you revoke it.5Use `storage_options` on any image or video request to **persist the generated asset** to your [Files API](/developers/files) storage, where you can retrieve it later through the authenticated Files API. On top of that, set `storage_options.public_url` to additionally generate a **permanent, shareable public URL** for the asset — an unauthenticated link that anyone can open and that stays alive until you revoke it.

6 6 

7Storage and public URL creation are independent: you can store privately without a public URL, or store with a public URL. Either way, the response also includes the ephemeral generation URL that's always returned by default.7Storage and public URL creation are independent: you can store privately without a public URL, or store with a public URL. Either way, the response also includes the ephemeral generation URL that's always returned by default.

8 8 


66 66 

67Key things to note:67Key things to note:

68 68 

69* `data[i].url` is the **ephemeral** Imagine URL — short-lived, fine for immediate use. It's always returned, regardless of whether `storage_options` is specified.69* `data[i].url` is the **ephemeral** generation URL — short-lived, fine for immediate use. It's always returned, regardless of whether `storage_options` is specified.

70* `data[i].file_output.file_id` is the stable Files API identifier for the generated asset.70* `data[i].file_output.file_id` is the stable Files API identifier for the generated asset.

71* `data[i].file_output.public_url` is the **permanent** public URL. Use this for sharing, embedding, and long-term storage in your app.71* `data[i].file_output.public_url` is the **permanent** public URL. Use this for sharing, embedding, and long-term storage in your app.

72 72 


109 109 

110`storage_options` exposes two independent expiry knobs: `storage_options.expires_after` controls when the **stored file** auto-deletes, and `storage_options.public_url.expires_after` controls when the **public URL** auto-revokes. Omit `public_url.expires_after` and the URL inherits the file's expiry (or never expires if the file has none).110`storage_options` exposes two independent expiry knobs: `storage_options.expires_after` controls when the **stored file** auto-deletes, and `storage_options.public_url.expires_after` controls when the **public URL** auto-revokes. Omit `public_url.expires_after` and the URL inherits the file's expiry (or never expires if the file has none).

111 111 

112A public URL can never outlive its file, and both values must be between **1 hour and 30 days**. See [Public URLs → Expiry Behaviour](/developers/files/public-urls#expiry-behaviour) for the full rules; the examples below show how the two knobs combine on an Imagine request.112A public URL can never outlive its file, and both values must be between **1 hour and 30 days**. See [Public URLs → Expiry Behaviour](/developers/files/public-urls#expiry-behaviour) for the full rules; the examples below show how the two knobs combine on an image or video request.

113 113 

114```bash114```bash

115# Permanent file, 24h public URL115# Permanent file, 24h public URL


187 187 

188## The `file_output` Response188## The `file_output` Response

189 189 

190Every Imagine response with `storage_options` set includes a `file_output` block on each generated asset:190Every image or video response with `storage_options` set includes a `file_output` block on each generated asset:

191 191 

192| Field | Always present | Meaning |192| Field | Always present | Meaning |

193| ----------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |193| ----------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |


366print(public_url)366print(public_url)

367```367```

368 368 

369## Managing Files Created via Imagine369## Managing Generated Files

370 370 

371Files created through `storage_options` are full first-class Files API files. Use the [Files API](/developers/files/managing-files) to list, retrieve, update, and delete them, and use the public URL endpoints to revoke or re-create the URL after the fact:371Files created through `storage_options` are full first-class Files API files. Use the [Files API](/developers/files/managing-files) to list, retrieve, update, and delete them, and use the public URL endpoints to revoke or re-create the URL after the fact:

372 372 

Details

4 4 

5Edit an existing video by providing a source video along with your prompt. The model understands the video content and applies your requested changes.5Edit an existing video by providing a source video along with your prompt. The model understands the video content and applies your requested changes.

6 6 

7You can provide the source video as a public URL, a base64-encoded data URI, or a `file_id` from the [Files API](/developers/files). See [Imagine → Files API Integration](/developers/model-capabilities/imagine/files/inputs) for using `file_id` inputs.7You can provide the source video as a public URL, a base64-encoded data URI, or a `file_id` from the [Files API](/developers/files). See [Files API integration for image & video requests](/developers/model-capabilities/imagine/files/inputs) for using `file_id` inputs.

8 8 

9| Requirement | Value |9| Requirement | Value |

10|-------------|-------|10|-------------|-------|


94* [Image-to-Video](/developers/model-capabilities/video/image-to-video) — Animate a still image94* [Image-to-Video](/developers/model-capabilities/video/image-to-video) — Animate a still image

95* [Video Extension](/developers/model-capabilities/video/extension) — Extend existing videos95* [Video Extension](/developers/model-capabilities/video/extension) — Extend existing videos

96* [API Reference](/developers/rest-api-reference) — Full endpoint documentation96* [API Reference](/developers/rest-api-reference) — Full endpoint documentation

97* [Imagine API Landing Page](https://x.ai/api/imagine) — Showcase of the Imagine API in action97* [Image & Video API Landing Page](https://x.ai/api/imagine) — Showcase of the image & video API in action

Details

4 4 

5Extend an existing video by providing a source video and a text prompt describing what should happen next. The result is a single video that picks up seamlessly from the last frame of the input and continues with the generated content.5Extend an existing video by providing a source video and a text prompt describing what should happen next. The result is a single video that picks up seamlessly from the last frame of the input and continues with the generated content.

6 6 

7You can provide the source video as a public URL, a base64-encoded data URI, or a `file_id` from the [Files API](/developers/files). See [Imagine → Files API Integration](/developers/model-capabilities/imagine/files/inputs) for using `file_id` inputs.7You can provide the source video as a public URL, a base64-encoded data URI, or a `file_id` from the [Files API](/developers/files). See [Files API integration for image & video requests](/developers/model-capabilities/imagine/files/inputs) for using `file_id` inputs.

8 8 

9| Requirement | Value |9| Requirement | Value |

10|-------------|-------|10|-------------|-------|


148* [Video Editing](/developers/model-capabilities/video/editing) — Edit existing videos148* [Video Editing](/developers/model-capabilities/video/editing) — Edit existing videos

149* [Image-to-Video](/developers/model-capabilities/video/image-to-video) — Animate a still image149* [Image-to-Video](/developers/model-capabilities/video/image-to-video) — Animate a still image

150* [API Reference](/developers/rest-api-reference) — Full endpoint documentation150* [API Reference](/developers/rest-api-reference) — Full endpoint documentation

151* [Imagine API Landing Page](https://x.ai/api/imagine) — Showcase of the Imagine API in action151* [Image & Video API Landing Page](https://x.ai/api/imagine) — Showcase of the image & video API in action

Details

745* [Video Extension](/developers/model-capabilities/video/extension) — Extend existing videos745* [Video Extension](/developers/model-capabilities/video/extension) — Extend existing videos

746* [Image Generation](/developers/model-capabilities/images/generation) — Generate still images from text746* [Image Generation](/developers/model-capabilities/images/generation) — Generate still images from text

747* [API Reference](/developers/rest-api-reference) — Full endpoint documentation747* [API Reference](/developers/rest-api-reference) — Full endpoint documentation

748* [Imagine API Landing Page](https://x.ai/api/imagine) — Showcase of the Imagine API in action748* [Image & Video API Landing Page](https://x.ai/api/imagine) — Showcase of the image & video API in action

Details

8 8 

9* A **public URL** pointing to an image9* A **public URL** pointing to an image

10* A **base64-encoded data URI** (e.g., `data:image/jpeg;base64,...`)10* A **base64-encoded data URI** (e.g., `data:image/jpeg;base64,...`)

11* A **`file_id`** from the [Files API](/developers/files) — see [Imagine → Files API Integration](/developers/model-capabilities/imagine/files/inputs)11* A **`file_id`** from the [Files API](/developers/files) — see [Files API integration for image & video requests](/developers/model-capabilities/imagine/files/inputs)

12 12 

13The demo below shows this in action; hold to animate a still image:13The demo below shows this in action; hold to animate a still image:

14 14 


22* [Videos API](/developers/rest-api-reference/inference/videos) — Video generation endpoints22* [Videos API](/developers/rest-api-reference/inference/videos) — Video generation endpoints

23* [Video Editing](/developers/model-capabilities/video/editing) — Edit existing videos23* [Video Editing](/developers/model-capabilities/video/editing) — Edit existing videos

24* [API Reference](/developers/rest-api-reference) — Full endpoint documentation24* [API Reference](/developers/rest-api-reference) — Full endpoint documentation

25* [Imagine API Landing Page](https://x.ai/api/imagine) — Showcase of the Imagine API in action25* [Image & Video API Landing Page](https://x.ai/api/imagine) — Showcase of the image & video API in action

Details

2 2 

3# Video Overview3# Video Overview

4 4 

5Grok Imagine video models turn a set of references, a still image, an existing clip, or a prompt into video with generated audio. `grok-imagine-video-1.5` generates lip-synced speech, renders text-to-video and image-to-video at native 1080p, takes up to 14 reference images and 3 voice references, and pins first, last, and mid-video frames, in clips up to 15 seconds. `grok-imagine-video-1.5-lite` does text-to-video and image-to-video with lip-synced speech at the lowest price per second, reaching 1080p by upscaling 720p. We recommend `grok-imagine-video-1.5-lite` for simple videos, and `grok-imagine-video-1.5` when you need references, voices, pinned frames, or native 1080p.5Grok video models turn a set of references, a still image, an existing clip, or a prompt into video with generated audio. `grok-imagine-video-1.5` generates lip-synced speech, renders text-to-video and image-to-video at native 1080p, takes up to 14 reference images and 3 voice references, and pins first, last, and mid-video frames, in clips up to 15 seconds. `grok-imagine-video-1.5-lite` does text-to-video and image-to-video with lip-synced speech at the lowest price per second, reaching 1080p by upscaling 720p. We recommend `grok-imagine-video-1.5-lite` for simple videos, and `grok-imagine-video-1.5` when you need references, voices, pinned frames, or native 1080p.

6 6 

7Requests are asynchronous: submit, poll with the returned `request_id`, then download the clip. The xAI SDK and the Vercel AI SDK poll for you ([how it works](/developers/model-capabilities/video/generation#how-it-works)).7Requests are asynchronous: submit, poll with the returned `request_id`, then download the clip. The xAI SDK and the Vercel AI SDK poll for you ([how it works](/developers/model-capabilities/video/generation#how-it-works)).

8 8 

Details

4 4 

5Provide reference images, a preset voice, or both to guide the generated video. Images incorporate specific people, objects, clothing, or other visual elements without locking the first frame (unlike [image-to-video](/developers/model-capabilities/video/image-to-video)). This is useful for virtual try-on, product placement, and stories with recurring characters. On `grok-imagine-video-1.5`, you can also pick the voice your subject speaks in (see [Reference audio](#reference-audio)), pin the exact first or last frame (see [First & Last frame](#first--last-frame)), and pin frames at chosen moments inside the clip (see [Keyframes](#keyframes)).5Provide reference images, a preset voice, or both to guide the generated video. Images incorporate specific people, objects, clothing, or other visual elements without locking the first frame (unlike [image-to-video](/developers/model-capabilities/video/image-to-video)). This is useful for virtual try-on, product placement, and stories with recurring characters. On `grok-imagine-video-1.5`, you can also pick the voice your subject speaks in (see [Reference audio](#reference-audio)), pin the exact first or last frame (see [First & Last frame](#first--last-frame)), and pin frames at chosen moments inside the clip (see [Keyframes](#keyframes)).

6 6 

7Each reference image can be provided as a public HTTPS URL, a base64-encoded data URI, or a `file_id` from the [Files API](/developers/files) — and you can mix kinds within a single request. See [Imagine → Files API Integration](/developers/model-capabilities/imagine/files/inputs) for `file_id` details and examples.7Each reference image can be provided as a public HTTPS URL, a base64-encoded data URI, or a `file_id` from the [Files API](/developers/files) — and you can mix kinds within a single request. See [Files API integration for image & video requests](/developers/model-capabilities/imagine/files/inputs) for `file_id` details and examples.

8 8 

9In the Vercel AI SDK, set `providerOptions.xai.mode` to `"reference-to-video"` and pass the images with `providerOptions.xai.referenceImageUrls`.9In the Vercel AI SDK, set `providerOptions.xai.mode` to `"reference-to-video"` and pass the images with `providerOptions.xai.referenceImageUrls`.

10 10 


415* [Image-to-Video](/developers/model-capabilities/video/image-to-video) — Animate a still image415* [Image-to-Video](/developers/model-capabilities/video/image-to-video) — Animate a still image

416* [Video Editing](/developers/model-capabilities/video/editing) — Edit existing videos416* [Video Editing](/developers/model-capabilities/video/editing) — Edit existing videos

417* [API Reference](/developers/rest-api-reference) — Full endpoint documentation417* [API Reference](/developers/rest-api-reference) — Full endpoint documentation

418* [Imagine API Landing Page](https://x.ai/api/imagine) — Showcase of the Imagine API in action418* [Image & Video API Landing Page](https://x.ai/api/imagine) — Showcase of the image & video API in action

quickstart.md +1 −1

Details

117 117 

118## Step 5: Generate an image118## Step 5: Generate an image

119 119 

120Use the Imagine API to generate images from text prompts:120Use the image API to generate images from text prompts:

121 121 

122```javascript customLanguage="javascriptAISDK"122```javascript customLanguage="javascriptAISDK"

123import { xai } from '@ai-sdk/xai';123import { xai } from '@ai-sdk/xai';

rate-limits.md +4 −4

Details

23 23 

24> [!NOTE]24> [!NOTE]

25>25>

26> Rate limit tiers apply to text, embedding, and voice models. For increases to Imagine API limits, contact [sales@x.ai](mailto:sales@x.ai).26> Rate limit tiers apply to text, embedding, and voice models. For increases to image & video model limits, contact [sales@x.ai](mailto:sales@x.ai).

27 27 

28## Per-model limits28## Per-model limits

29 29 


41| grok-4.20-0309-non-reasoning | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |41| grok-4.20-0309-non-reasoning | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |

42| grok-build-0.1 | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |42| grok-build-0.1 | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |

43| grok-4.20-multi-agent-0309 | T0: 9, T1: 12, T2: 18, T3: 31, T4: 56 | T0: 2.5M, T1: 3.7M, T2: 6.2M, T3: 11M, T4: 21M |43| grok-4.20-multi-agent-0309 | T0: 9, T1: 12, T2: 18, T3: 31, T4: 56 | T0: 2.5M, T1: 3.7M, T2: 6.2M, T3: 11M, T4: 21M |

44| grok-imagine-image-2.0 | T0: 6, T1: 12, T2: 25, T3: 50, T4: 100 | — |

45| grok-imagine-image | T0: 6, T1: 12, T2: 25, T3: 50, T4: 100 | — |44| grok-imagine-image | T0: 6, T1: 12, T2: 25, T3: 50, T4: 100 | — |

46| grok-imagine-video-1.5 | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |45| grok-imagine-image-2.0 | T0: 6, T1: 12, T2: 25, T3: 50, T4: 100 | — |

47| grok-imagine-video-1.5-lite | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |

48| grok-imagine-video | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |46| grok-imagine-video | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |

47| grok-imagine-video-1.5-lite | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |

48| grok-imagine-video-1.5 | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |

49 49 

50**Voice & Audio**50**Voice & Audio**

51 51 

Details

2 2 

3# Image Generation Tool3# Image Generation Tool

4 4 

5The image generation tool lets Grok create and edit images with [Grok Imagine](/developers/model-capabilities/images/generation) as part of a conversation. It uses the latest Imagine image models (`grok-imagine-image-2.0`). You hand the model the tool; it decides when to call it, writes the image prompt, picks an aspect ratio, and returns the finished image alongside its text response. Because the tool runs server-side, the model can also chain calls—generating an image and then editing it—within a single request.5The image generation tool lets Grok create and edit images with [Grok image models](/developers/model-capabilities/images/generation) as part of a conversation. It uses the latest image models (`grok-imagine-image-2.0`). You hand the model the tool; it decides when to call it, writes the image prompt, picks an aspect ratio, and returns the finished image alongside its text response. Because the tool runs server-side, the model can also chain calls—generating an image and then editing it—within a single request.

6 6 

7If you already have the exact prompt and want direct control over aspect ratio and resolution, call the [image generation](/developers/model-capabilities/images/generation) and [image editing](/developers/model-capabilities/images/editing) endpoints instead. Reach for the tool when image creation is one step in a larger conversational or agentic workflow.7If you already have the exact prompt and want direct control over aspect ratio and resolution, call the [image generation](/developers/model-capabilities/images/generation) and [image editing](/developers/model-capabilities/images/editing) endpoints instead. Reach for the tool when image creation is one step in a larger conversational or agentic workflow.

8 8