SpyBara
Go Premium

Documentation 2026-08-18 04:01 UTC to 2026-08-19 18:02 UTC

22 files changed +190 −47. View all changes and history on the product overview
2026
Fri 21 18:57 Thu 20 15:58 Wed 19 18:02 Tue 18 04:01 Thu 13 22:00 Wed 12 23:59 Tue 11 20:57 Sat 8 23:00 Fri 7 17:57 Thu 6 20:01 Mon 3 23:00 Sat 1 01:59
Details

28 28 

29> [!NOTE]29> [!NOTE]

30>30>

31> You can also create, monitor, and manage batches through the [xAI Console](https://console.x.ai/team/default/batches). The Console provides a visual interface for tracking batch progress and viewing results.31> You can also create, monitor, and manage batches through the [xAI Console](https://console.x.ai/team/default/batches?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-advanced-api-usage-batch-api\&utm_content=batches). The Console provides a visual interface for tracking batch progress and viewing results.

32 32 

33## When to use the Batch API33## When to use the Batch API

34 34 

Details

10 10 

11> [!TIP]11> [!TIP]

12>12>

13> Your deferred completion rate limit is the same as your chat completions rate limit. To view your rate limit, please visit [xAI Console](https://console.x.ai).13> Your deferred completion rate limit is the same as your chat completions rate limit. To view your rate limit, please visit [xAI Console](https://console.x.ai?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-advanced-api-usage-deferred-chat-completions\&utm_content=console-home).

14 14 

15After sending the request to the xAI API, the chat completion result will be available at `https://api.x.ai/v1/chat/deferred-completion/{request_id}`. The response body will contain `{'request_id': 'f15c114e-f47d-40ca-8d5c-8c23d656eeb6'}`, and the `request_id` value can be inserted into the `deferred-completion` endpoint path. Then, we send this GET request to retrieve the deferred completion result.15After sending the request to the xAI API, the chat completion result will be available at `https://api.x.ai/v1/chat/deferred-completion/{request_id}`. The response body will contain `{'request_id': 'f15c114e-f47d-40ca-8d5c-8c23d656eeb6'}`, and the `request_id` value can be inserted into the `deferred-completion` endpoint path. Then, we send this GET request to retrieve the deferred completion result.

16 16 

Details

20 20 

21Contact [support@x.ai](mailto:support@x.ai) with:21Contact [support@x.ai](mailto:support@x.ai) with:

22 22 

23* Your team ID (found in the [xAI Console](https://console.x.ai))23* Your team ID (found in the [xAI Console](https://console.x.ai?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-advanced-api-usage-mtls\&utm_content=console-home))

24* Your CA certificate in PEM format24* Your CA certificate in PEM format

25* The Common Name (CN) from the client certificates your systems will use25* The Common Name (CN) from the client certificates your systems will use

26 26 

debugging.md +2 −2

Details

24| Status | Endpoints | Cause | Solution |24| Status | Endpoints | Cause | Solution |

25| --------------------------------------------------------------------------------------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |25| --------------------------------------------------------------------------------------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |

26| **400**Bad Request | All endpoints | | Check your request body or request URL. |26| **400**Bad Request | All endpoints | | Check your request body or request URL. |

27| **401**Unauthorized | All endpoints | No authorization header or an invalid authorization token was provided. | Supply an `Authorization: Bearer <XAI_API_KEY>` header. You can get a new API key on [xAI Console](https://console.x.ai). |27| **401**Unauthorized | All endpoints | No authorization header or an invalid authorization token was provided. | Supply an `Authorization: Bearer <XAI_API_KEY>` header. You can get a new API key on [xAI Console](https://console.x.ai?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-debugging\&utm_content=console-home). |

28| **403**Forbidden | All endpoints | | Ask your team admin for permission. |28| **403**Forbidden | All endpoints | | Ask your team admin for permission. |

29| **404**Not Found | All endpoints | | Check your request body and endpoint URL against the [API Reference](/developers/rest-api-reference). |29| **404**Not Found | All endpoints | | Check your request body and endpoint URL against the [API Reference](/developers/rest-api-reference). |

30| **405**Method Not Allowed | All endpoints | The request method is not allowed. For example, sending a `POST` to an endpoint that only supports `GET`. | Check your request method against the [API Reference](/developers/rest-api-reference). |30| **405**Method Not Allowed | All endpoints | The request method is not allowed. For example, sending a `POST` to an endpoint that only supports `GET`. | Check your request method against the [API Reference](/developers/rest-api-reference). |

31| **415**Unsupported Media Type | Endpoints supporting `POST` | | |31| **415**Unsupported Media Type | Endpoints supporting `POST` | | |

32| **422**Unprocessable Entity | Endpoints supporting `POST` | A field in the `POST` request body has an invalid format. | Check your request body against the [API Reference](/developers/rest-api-reference). |32| **422**Unprocessable Entity | Endpoints supporting `POST` | A field in the `POST` request body has an invalid format. | Check your request body against the [API Reference](/developers/rest-api-reference). |

33| **429**Too Many Requests | Inference endpoints | You are sending requests too frequently and have reached the rate limit. | Reduce your request rate or increase your rate limit on [xAI Console](https://console.x.ai). |33| **429**Too Many Requests | Inference endpoints | You are sending requests too frequently and have reached the rate limit. | Reduce your request rate or increase your rate limit on [xAI Console](https://console.x.ai?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-debugging\&utm_content=console-home). |

34 34 

35### 2XX Status Codes35### 2XX Status Codes

36 36 

faq/accounts.md +2 −2

Details

4 4 

5## How do I create an account for the API?5## How do I create an account for the API?

6 6 

7You can create an account at https://accounts.x.ai, or https://console.x.ai. To link your X account automatically to7You can create an account at [console.x.ai](https://console.x.ai/login?mode=sign-up\&utm_source=docs\&utm_medium=referral\&utm_campaign=faq-accounts). To link your X account automatically to

8your xAI account, choose to sign up with X account.8your xAI account, choose to sign up with X account.

9 9 

10> [!WARNING]10> [!WARNING]


35 35 

36Yes, the account is shared between Grok and xAI API. You can manage the sign-in details at https://accounts.x.ai.36Yes, the account is shared between Grok and xAI API. You can manage the sign-in details at https://accounts.x.ai.

37 37 

38However, the billing is separate for Grok and xAI API. You can manage your billing for xAI API on [xAI Console](https://console.x.ai).38However, the billing is separate for Grok and xAI API. You can manage your billing for xAI API on [xAI Console](https://console.x.ai?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-faq-accounts\&utm_content=console-home).

39To manage billing for Grok, visit https://grok.com -> Settings -> Billing, or directly with Apple/Google if you made the39To manage billing for Grok, visit https://grok.com -> Settings -> Billing, or directly with Apple/Google if you made the

40purchase via Apple App Store or Google Play.40purchase via Apple App Store or Google Play.

41 41 

faq/billing.md +1 −1

Details

22 22 

23## Can you retroactively generate an invoice with new billing information?23## Can you retroactively generate an invoice with new billing information?

24 24 

25We are unable to retroactively generate an invoice. Please ensure your billing information is correct on [xAI Console](https://console.x.ai) Billing -> Payment.25We are unable to retroactively generate an invoice. Please ensure your billing information is correct on [xAI Console](https://console.x.ai?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-faq-billing\&utm_content=console-home) Billing -> Payment.

26 26 

27## Can prepaid API credits be refunded?27## Can prepaid API credits be refunded?

28 28 

faq/security.md +4 −4

Details

20 20 

21* **No storage of prompts:** ZDR ensures that API request inputs (i.e., your prompt) and outputs (i.e., the tokens generated by the LLM) are never persisted to disk. The 30-day audit retention described above does not apply to ZDR-enabled teams.21* **No storage of prompts:** ZDR ensures that API request inputs (i.e., your prompt) and outputs (i.e., the tokens generated by the LLM) are never persisted to disk. The 30-day audit retention described above does not apply to ZDR-enabled teams.

22* **Applied at a team level:** If enabled, ZDR is team-wide. There is no ability to enable ZDR for specific API keys.22* **Applied at a team level:** If enabled, ZDR is team-wide. There is no ability to enable ZDR for specific API keys.

23* **Self-serve:** Where available, a team admin can turn it on or off directly from the [xAI Console](https://console.x.ai/team/default/settings/team). When enabled, it applies to every API key on the team.23* **Self-serve:** Where available, a team admin can turn it on or off directly from the [xAI Console](https://console.x.ai/team/default/settings/team?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-faq-security\&utm_content=team-settings). When enabled, it applies to every API key on the team.

24 24 

25### Features not supported with ZDR25### Features not supported with ZDR

26 26 


41 41 

42Team admins can enable or disable ZDR from the Console:42Team admins can enable or disable ZDR from the Console:

43 43 

441. Sign in to the [xAI Console](https://console.x.ai/) as a team admin and select the team you want to change in the team picker.441. Sign in to the [xAI Console](https://console.x.ai/?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-faq-security\&utm_content=console-home) as a team admin and select the team you want to change in the team picker.

452. Delete any existing [Files](/developers/files) and [Collections](/developers/files/collections) for that team. The Console blocks Enable while stored files or collections remain.452. Delete any existing [Files](/developers/files) and [Collections](/developers/files/collections) for that team. The Console blocks Enable while stored files or collections remain.

463. Open **Team Settings** and find the **Zero Data Retention (ZDR)** row, then click **Enable**.463. Open **Team Settings** and find the **Zero Data Retention (ZDR)** row, then click **Enable**.

474. Review the acknowledgments in the confirmation dialog, including that deleted User Content cannot be recovered, and accept the Enterprise Terms and Privacy Policy. Click **Enable** to confirm.474. Review the acknowledgments in the confirmation dialog, including that deleted User Content cannot be recovered, and accept the Enterprise Terms and Privacy Policy. Click **Enable** to confirm.


53### How to check that ZDR is enabled53### How to check that ZDR is enabled

54 54 

55* **Team Settings:** the **Zero Data Retention (ZDR)** row shows an **Active** badge.55* **Team Settings:** the **Zero Data Retention (ZDR)** row shows an **Active** badge.

56* **Team picker:** the [xAI Console](https://console.x.ai/) team picker shows a **ZDR** badge next to your team name (tooltip: Zero Data Retention).56* **Team picker:** the [xAI Console](https://console.x.ai/?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-faq-security\&utm_content=console-home) team picker shows a **ZDR** badge next to your team name (tooltip: Zero Data Retention).

57* **Response header:** every API response includes an `x-zero-data-retention` header set to `"true"` or `"false"`, so your application can programmatically confirm whether ZDR is active.57* **Response header:** every API response includes an `x-zero-data-retention` header set to `"true"` or `"false"`, so your application can programmatically confirm whether ZDR is active.

58* **Audit logs:** administrative events (key creation, team changes, etc.) still appear in the Console audit log, but the content of API requests and responses does not.58* **Audit logs:** administrative events (key creation, team changes, etc.) still appear in the Console audit log, but the content of API requests and responses does not.

59 59 


81 81 

82## Do you have Audit Logs?82## Do you have Audit Logs?

83 83 

84Team admins are able to view an audit log of user interactions. This lists all of the user interactions with our API server. You can view it at [xAI Console -> Audit Log](https://console.x.ai/team/default/audit).84Team admins are able to view an audit log of user interactions. This lists all of the user interactions with our API server. You can view it at [xAI Console -> Audit Log](https://console.x.ai/team/default/audit?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-faq-security\&utm_content=audit).

85 85 

86The admin can also search by Event ID, Description, or User to filter the results shown. For example, this is to filter by description matching `ListApiKeys`:86The admin can also search by Event ID, Description, or User to filter the results shown. For example, this is to filter by description matching `ListApiKeys`:

87 87 

Details

14 14 

15## Which team am I on?15## Which team am I on?

16 16 

17When you sign up for xAI, you’re automatically assigned to a **Personal Team**, which you can view the top bar of [xAI Console](https://console.x.ai).17When you sign up for xAI, you’re automatically assigned to a **Personal Team**, which you can view the top bar of [xAI Console](https://console.x.ai?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-faq-team-management\&utm_content=console-home).

18 18 

19## How can I manage teams and team members?19## How can I manage teams and team members?

20 20 


26 26 

27### Rename or Describe a Team27### Rename or Describe a Team

28 28 

29Admins can update the team name and description on the [Settings page](https://console.x.ai/team/default/settings).29Admins can update the team name and description on the [Settings page](https://console.x.ai/team/default/settings?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-faq-team-management\&utm_content=settings).

30 30 

31### Manage Team Members31### Manage Team Members

32 32 

33Admins can add or remove members by email on the [Users page](https://console.x.ai/team/default/users).33Admins can add or remove members by email on the [Users page](https://console.x.ai/team/default/users?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-faq-team-management\&utm_content=users).

34 34 

35* Assign members as **Admin** or **Member**.35* Assign members as **Admin** or **Member**.

36* If a user is removed, their API keys remain with the team.36* If a user is removed, their API keys remain with the team.


43 43 

44To permanently delete a team:44To permanently delete a team:

45 45 

461. Go to the [Settings page](https://console.x.ai/team/default/settings).461. Go to the [Settings page](https://console.x.ai/team/default/settings?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-faq-team-management\&utm_content=settings).

472. Follow the instructions under **Delete Team**.472. Follow the instructions under **Delete Team**.

48 48 

49## How to automatically add users to team with my organization's email domain?49## How to automatically add users to team with my organization's email domain?

50 50 

51Admins can enable automatic team joining for users with a shared email domain:51Admins can enable automatic team joining for users with a shared email domain:

52 52 

531. Go to the [Settings page](https://console.x.ai/team/default/settings).531. Go to the [Settings page](https://console.x.ai/team/default/settings?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-faq-team-management\&utm_content=settings).

542. Add the domain under **Verified Domains**.542. Add the domain under **Verified Domains**.

553. Add a `domain-verification` key to your domain’s DNS TXT record to verify ownership.553. Add a `domain-verification` key to your domain’s DNS TXT record to verify ownership.

56 56 

Details

8 8 

9To use the Collections API, you need to create a Management API Key with the `AddFileToCollection` permission. This permission is required for uploading documents to collections.9To use the Collections API, you need to create a Management API Key with the `AddFileToCollection` permission. This permission is required for uploading documents to collections.

10 10 

111. Navigate to the **Management Keys** section in the [xAI Console](https://console.x.ai/team/default/settings/management-keys)111. Navigate to the **Management Keys** section in the [xAI Console](https://console.x.ai/team/default/settings/management-keys?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-files-collections-api\&utm_content=management-keys)

122. Click on **Create Management Key**122. Click on **Create Management Key**

133. Select the `AddFileToCollection` permission along with any other permissions you need133. Select the `AddFileToCollection` permission along with any other permissions you need

144. If you need to perform operations other than uploading documents (such as creating, updating, or deleting collections), enable the corresponding permissions in the **Collections Endpoint** group144. If you need to perform operations other than uploading documents (such as creating, updating, or deleting collections), enable the corresponding permissions in the **Collections Endpoint** group

Details

4 4 

5The Files API provides a complete set of operations for managing your files. If your files are publicly accessible, you can reference them directly by URL in chat conversations — see [Attaching Files](/developers/model-capabilities/files/chat-with-files#attaching-files). For files that aren't publicly accessible, upload them using one of the methods described below.5The Files API provides a complete set of operations for managing your files. If your files are publicly accessible, you can reference them directly by URL in chat conversations — see [Attaching Files](/developers/model-capabilities/files/chat-with-files#attaching-files). For files that aren't publicly accessible, upload them using one of the methods described below.

6 6 

7You can also view and manage all of your uploaded files from the [Files page](https://console.x.ai/team/default/files) on the xAI Console.7You can also view and manage all of your uploaded files from the [Files page](https://console.x.ai/team/default/files?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-files-managing-files\&utm_content=files) on the xAI Console.

8 8 

9## Uploading Files9## Uploading Files

10 10 

grok-4-6.md +2 −2

Details

6 6 

7## Using the API7## Using the API

8 8 

9If you already have an [API key](https://console.x.ai/team/default/api-keys), set the model name to `grok-4.6`:9If you already have an [API key](https://console.x.ai/team/default/api-keys?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-grok-4-6\&utm_content=api-keys), set the model name to `grok-4.6`:

10 10 

11```python customLanguage="pythonXAI"11```python customLanguage="pythonXAI"

12import os12import os


95 95 

96## Where it runs96## Where it runs

97 97 

98* **xAI API**: get a key from the [console](https://console.x.ai/)98* **xAI API**: get a key from the [console](https://console.x.ai/?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-grok-4-6\&utm_content=console-home)

99* **Grok Build**: the default model of the [coding agent](/build/overview), on the API and CLI99* **Grok Build**: the default model of the [coding agent](/build/overview), on the API and CLI

100* **Cursor**: available on all plans100* **Cursor**: available on all plans

101* **Model gateways**: OpenRouter, Vercel, and Cloudflare101* **Model gateways**: OpenRouter, Vercel, and Cloudflare

Details

6 6 

7You can read the endpoint specifications and descriptions at [Management API Reference](/developers/rest-api-reference/management).7You can read the endpoint specifications and descriptions at [Management API Reference](/developers/rest-api-reference/management).

8 8 

9You need to get a management key, which is separate from your API key, to use the management API. The management key can be obtained at [xAI Console](https://console.x.ai) -> Settings -> Management Keys.9You need to get a management key, which is separate from your API key, to use the management API. The management key can be obtained at [xAI Console](https://console.x.ai?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-management-api-guide\&utm_content=console-home) -> Settings -> Management Keys.

10 10 

11The base URL is at `https://management-api.x.ai`, which is also different from the inference API.11The base URL is at `https://management-api.x.ai`, which is also different from the inference API.

12 12 

Details

10 10 

11## How to Use Custom Voices11## How to Use Custom Voices

12 12 

13After creating a voice in the [console](https://console.x.ai/team/default/voice/voice-library?campaign=voice-docs-custom-voices), click the three-dot menu on the voice card and select **Copy Voice ID**. If you created a custom voice via the API (Enterprise only), the `voice_id` is returned in the response.13After creating a voice in the [console](https://console.x.ai/team/default/voice/voice-library?campaign=voice-docs-custom-voices\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-audio-custom-voices\&utm_content=voice-library), click the three-dot menu on the voice card and select **Copy Voice ID**. If you created a custom voice via the API (Enterprise only), the `voice_id` is returned in the response.

14 14 

15Custom voices are interchangeable with built-in voices across all voice APIs. Pass your `voice_id` to any of:15Custom voices are interchangeable with built-in voices across all voice APIs. Pass your `voice_id` to any of:

16 16 


52 52 

53Get started in the console — create up to 30 custom voices for free and use them immediately across all voice APIs.53Get started in the console — create up to 30 custom voices for free and use them immediately across all voice APIs.

54 54 

55[Clone Voice in Console](https://console.x.ai/team/default/voice/voice-library?campaign=voice-docs-custom-voices)55[Clone Voice in Console](https://console.x.ai/team/default/voice/voice-library?campaign=voice-docs-custom-voices\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-audio-custom-voices\&utm_content=voice-library)

56 56 

57### API Quick Start57### API Quick Start

58 58 


540| `200` | Successful read / update / delete | - |540| `200` | Successful read / update / delete | - |

541| `400` | Bad request | Check: audio under 120 s; label values are within the allowed enums; PATCH does not contain empty strings. Also returned when the team's 30-voice limit is reached — delete an existing voice or [request more](https://x.ai/contact-sales). |541| `400` | Bad request | Check: audio under 120 s; label values are within the allowed enums; PATCH does not contain empty strings. Also returned when the team's 30-voice limit is reached — delete an existing voice or [request more](https://x.ai/contact-sales). |

542| `401` | Unauthorized | API key is missing or invalid. |542| `401` | Unauthorized | API key is missing or invalid. |

543| `403` | Custom voices not enabled for this team, or `POST /v1/custom-voices` was called without an Enterprise contract | Create voices in the [console playground](https://console.x.ai/team/default/voice/voice-library?campaign=voice-docs-custom-voices), or [contact sales](https://x.ai/contact-sales) to enable the create API. |543| `403` | Custom voices not enabled for this team, or `POST /v1/custom-voices` was called without an Enterprise contract | Create voices in the [console playground](https://console.x.ai/team/default/voice/voice-library?campaign=voice-docs-custom-voices\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-audio-custom-voices\&utm_content=voice-library), or [contact sales](https://x.ai/contact-sales) to enable the create API. |

544| `404` | Voice not found | The id does not exist or is owned by another team. |544| `404` | Voice not found | The id does not exist or is owned by another team. |

545| `500` | Server error | Retry with exponential backoff. |545| `500` | Server error | Retry with exponential backoff. |

Details

87 87 

88```88```

89 89 

90[Get API Key →](https://console.x.ai/team/default/api-keys?campaign=voice-docs-agent)90[Get API Key →](https://console.x.ai/team/default/api-keys?campaign=voice-docs-agent\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-audio-speech-to-speech\&utm_content=api-keys)

91 91 

92[API documentation](/developers/rest-api-reference/inference/voice#realtime)92[API documentation](/developers/rest-api-reference/inference/voice#realtime)

93 93 

Details

69 69 

70Note: The `file` parameter must be provided after all other parameters in the multipart form.70Note: The `file` parameter must be provided after all other parameters in the multipart form.

71 71 

72[Get API Key →](https://console.x.ai/team/default/api-keys?campaign=voice-docs-stt)72[Get API Key →](https://console.x.ai/team/default/api-keys?campaign=voice-docs-stt\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-audio-speech-to-text\&utm_content=api-keys)

73 73 

74[Live Voice Demos](https://x.ai/api/voice)74[Live Voice Demos](https://x.ai/api/voice)

75 75 

Details

91 91 

92The response body contains raw audio bytes. Save directly to a file or pipe to an audio player.92The response body contains raw audio bytes. Save directly to a file or pipe to an audio player.

93 93 

94[Try the Playground →](https://console.x.ai/team/default/voice/text-to-speech?campaign=voice-docs-tts)94[Try the Playground →](https://console.x.ai/team/default/voice/text-to-speech?campaign=voice-docs-tts\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-audio-text-to-speech\&utm_content=text-to-speech)

95 95 

96[Live Voice Demos](https://x.ai/api/voice)96[Live Voice Demos](https://x.ai/api/voice)

97 97 

98[Get API Key](https://console.x.ai/team/default/api-keys?campaign=voice-docs-tts)98[Get API Key](https://console.x.ai/team/default/api-keys?campaign=voice-docs-tts\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-audio-text-to-speech\&utm_content=api-keys)

99 99 

100## Request Body100## Request Body

101 101 


131 131 

132Each voice has a distinct personality. Listen to samples and choose the best fit for your use case (`eve` is the default):132Each voice has a distinct personality. Listen to samples and choose the best fit for your use case (`eve` is the default):

133 133 

134Voice IDs are **case-insensitive** - `eve`, `Eve`, and `EVE` all work. [Preview all voices in the playground →](https://console.x.ai/team/default/voice/text-to-speech?campaign=voice-docs-tts)134Voice IDs are **case-insensitive** - `eve`, `Eve`, and `EVE` all work. [Preview all voices in the playground →](https://console.x.ai/team/default/voice/text-to-speech?campaign=voice-docs-tts\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-audio-text-to-speech\&utm_content=text-to-speech)

135 135 

136### Custom voices136### Custom voices

137 137 

138Clone any voice from a short reference clip with the [Custom Voices API](/developers/model-capabilities/audio/custom-voices), or create one for free in the [console](https://console.x.ai/team/default/voice/voice-library?campaign=voice-docs-tts). To find your custom voice ID in the console, click the three-dot menu on the voice card and select **Copy Voice ID**. Then pass it as `voice_id`:138Clone any voice from a short reference clip with the [Custom Voices API](/developers/model-capabilities/audio/custom-voices), or create one for free in the [console](https://console.x.ai/team/default/voice/voice-library?campaign=voice-docs-tts\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-audio-text-to-speech\&utm_content=voice-library). To find your custom voice ID in the console, click the three-dot menu on the voice card and select **Copy Voice ID**. Then pass it as `voice_id`:

139 139 

140```bash140```bash

141# Replace YOUR_VOICE_ID with your custom voice ID from the console141# Replace YOUR_VOICE_ID with your custom voice ID from the console


810 810 

811### Integrating with AI coding assistants811### Integrating with AI coding assistants

812 812 

813The [Cloud Console playground](https://console.x.ai/team/default/voice/text-to-speech?campaign=voice-docs-tts) includes ready-made **agent instructions** you can copy and paste into tools like Cursor, GitHub Copilot, or Windsurf. The instructions are pre-configured with your current voice and format settings - open the playground, tweak your settings, and copy the prompt to get a tailored integration guide for your coding agent.813The [Cloud Console playground](https://console.x.ai/team/default/voice/text-to-speech?campaign=voice-docs-tts\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-audio-text-to-speech\&utm_content=text-to-speech) includes ready-made **agent instructions** you can copy and paste into tools like Cursor, GitHub Copilot, or Windsurf. The instructions are pre-configured with your current voice and format settings - open the playground, tweak your settings, and copy the prompt to get a tailored integration guide for your coding agent.

814 814 

815### Optimizing for production815### Optimizing for production

816 816 


1445 1445 

1446## Related1446## Related

1447 1447 

1448* [TTS Playground](https://console.x.ai/team/default/voice/text-to-speech?campaign=voice-docs-tts) - Try voices and speech tags in your browser1448* [TTS Playground](https://console.x.ai/team/default/voice/text-to-speech?campaign=voice-docs-tts\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-audio-text-to-speech\&utm_content=text-to-speech) - Try voices and speech tags in your browser

1449* [Create an API Key](https://console.x.ai/team/default/api-keys?campaign=voice-docs-tts) - Get started with the API1449* [Create an API Key](https://console.x.ai/team/default/api-keys?campaign=voice-docs-tts\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-audio-text-to-speech\&utm_content=api-keys) - Get started with the API

1450* [Voice Overview](/developers/model-capabilities/audio/voice) - Overview of all xAI voice capabilities1450* [Voice Overview](/developers/model-capabilities/audio/voice) - Overview of all xAI voice capabilities

1451* [Speech to Speech API](/developers/model-capabilities/audio/speech-to-speech) - Real-time voice conversations via WebSocket1451* [Speech to Speech API](/developers/model-capabilities/audio/speech-to-speech) - Real-time voice conversations via WebSocket

1452* [API Reference](/developers/rest-api-reference/inference/voice#text-to-speech---rest) - Full TTS endpoint specification1452* [API Reference](/developers/rest-api-reference/inference/voice#text-to-speech---rest) - Full TTS endpoint specification

Details

10 10 

11## Prerequisites11## Prerequisites

12 12 

13Create an API key on the [xAI Console API Keys Page](https://console.x.ai/team/default/api-keys). Set your API key in your environment:13Create an API key on the [xAI Console API Keys Page](https://console.x.ai/team/default/api-keys?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-legacy-chat-completions\&utm_content=api-keys). Set your API key in your environment:

14 14 

15```bash15```bash

16export XAI_API_KEY="your_api_key"16export XAI_API_KEY="your_api_key"

Details

13 13 

14## Prerequisites14## Prerequisites

15 15 

16Create an API key on the [xAI Console API Keys Page](https://console.x.ai/team/default/api-keys). Set your API key in your environment:16Create an API key on the [xAI Console API Keys Page](https://console.x.ai/team/default/api-keys?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-model-capabilities-text-generate-text\&utm_content=api-keys). Set your API key in your environment:

17 17 

18```bash18```bash

19export XAI_API_KEY="your_api_key"19export XAI_API_KEY="your_api_key"

quickstart.md +2 −2

Details

6 6 

7## Step 1: Create an xAI account7## Step 1: Create an xAI account

8 8 

9Sign up for an account at [accounts.x.ai](https://accounts.x.ai/sign-up?redirect=cloud-console), then load it with credits to start using the API.9Sign up for an account at [console.x.ai](https://console.x.ai/login?mode=sign-up\&utm_source=docs\&utm_medium=referral\&utm_campaign=quickstart), then load it with credits to start using the API.

10 10 

11## Step 2: Generate an API key11## Step 2: Generate an API key

12 12 

13Create an API key via the [API Keys page](https://console.x.ai/team/default/api-keys), then export it or add it as an environment variable.13Create an API key via the [API Keys page](https://console.x.ai/team/default/api-keys?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-quickstart\&utm_content=api-keys), then export it or add it as an environment variable.

14 14 

15```bash15```bash

16export XAI_API_KEY="your_api_key"16export XAI_API_KEY="your_api_key"

rate-limits.md +5 −5

Details

4 4 

5Every xAI API team has per-model rate limits on two dimensions: **requests per second (RPS)** and **tokens per minute (TPM)**. Your per-second limit is derived from your per-minute request budget (RPM / 60): you cannot spend a full minute's requests in a single second, which protects the API from sudden bursts. These limits scale with your team's **tier**, which is determined by cumulative spend on the API.5Every xAI API team has per-model rate limits on two dimensions: **requests per second (RPS)** and **tokens per minute (TPM)**. Your per-second limit is derived from your per-minute request budget (RPM / 60): you cannot spend a full minute's requests in a single second, which protects the API from sudden bursts. These limits scale with your team's **tier**, which is determined by cumulative spend on the API.

6 6 

7You can view your team's current tier and per-model limits on the [Rate Limits](https://console.x.ai/team/default/rate-limits) page in the xAI Console.7You can view your team's current tier and per-model limits on the [Rate Limits](https://console.x.ai/team/default/rate-limits?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-rate-limits\&utm_content=rate-limits) page in the xAI Console.

8 8 

9## Rate limit tiers9## Rate limit tiers

10 10 


29 29 

30Each tier sets hard RPS and TPM caps per model. Limits scale exponentially with tier. Exceeding any limit returns a `429 Too Many Requests` error.30Each tier sets hard RPS and TPM caps per model. Limits scale exponentially with tier. Exceeding any limit returns a `429 Too Many Requests` error.

31 31 

32The table below lists RPS and TPM limits at each tier for every model. You can also view your team's personalized limits on the [Rate Limits](https://console.x.ai/team/default/rate-limits) page in the xAI Console.32The table below lists RPS and TPM limits at each tier for every model. You can also view your team's personalized limits on the [Rate Limits](https://console.x.ai/team/default/rate-limits?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-rate-limits\&utm_content=rate-limits) page in the xAI Console.

33 33 

34| Model | RPS | TPM |34| Model | RPS | TPM |

35| --- | --- | --- |35| --- | --- | --- |


40| 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 |40| 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-build-0.1 | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |41| 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-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 |42| 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-imagine-image | T0: 6, T1: 12, T2: 25, T3: 50, T4: 100 | — |

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

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

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 | — |

46| 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 | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |47| grok-imagine-video-1.5 | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |

48 48 


105## Increasing your limits105## Increasing your limits

106 106 

107* **Spend more.** Tiers upgrade automatically based on cumulative spend. No action required on your part.107* **Spend more.** Tiers upgrade automatically based on cumulative spend. No action required on your part.

108* **Request an increase.** Submit a request through the [xAI Console](https://console.x.ai/team/default/rate-limits) if you need higher limits without additional spend, or limits beyond Tier 4.108* **Request an increase.** Submit a request through the [xAI Console](https://console.x.ai/team/default/rate-limits?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-rate-limits\&utm_content=rate-limits) if you need higher limits without additional spend, or limits beyond Tier 4.

109* **Contact sales.** For enterprise-grade capacity, please email [sales@x.ai](mailto:sales@x.ai).109* **Contact sales.** For enterprise-grade capacity, please email [sales@x.ai](mailto:sales@x.ai).

Details

3# Management REST API Overview3# Management REST API Overview

4 4 

5The Management API allows you to perform operations on your team programmatically. You5The Management API allows you to perform operations on your team programmatically. You

6need a [management key](https://console.x.ai/team/default/management-keys) in6need a [management key](https://console.x.ai/team/default/management-keys?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-rest-api-reference-management\&utm_content=management-keys) in

7order to use this API. The base URL for all endpoints is `https://management-api.x.ai`.7order to use this API. The base URL for all endpoints is `https://management-api.x.ai`.

8 8 

9The Management API serves as a dedicated interface to the xAI platform, empowering developers and teams to9The Management API serves as a dedicated interface to the xAI platform, empowering developers and teams to


14(ACLs). This API also facilitates oversight of billing aspects, including monitoring prepaid credit balances and usage14(ACLs). This API also facilitates oversight of billing aspects, including monitoring prepaid credit balances and usage

15deductions, ensuring seamless scalability and cost transparency for Grok model integrations.15deductions, ensuring seamless scalability and cost transparency for Grok model integrations.

16 16 

17To get started, go to [xAI Console](https://console.x.ai). On users page, make sure your xAI account has17To get started, go to [xAI Console](https://console.x.ai?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-rest-api-reference-management\&utm_content=console-home). On users page, make sure your xAI account has

18`Management Keys` Read + Write permission, and obtain your Management API key on the settings page. If you don't see18`Management Keys` Read + Write permission, and obtain your Management API key on the settings page. If you don't see

19any of these options, please ask your team administrator to enable the appropriate permissions.19any of these options, please ask your team administrator to enable the appropriate permissions.

20 20 

Details

10 10 

11| SDK/API | Tool Name |11| SDK/API | Tool Name |

12|---------|-----------|12|---------|-----------|

13| xAI SDK | `image_generation` |

13| OpenAI Responses API | `image_generation` |14| OpenAI Responses API | `image_generation` |

14 15 

15This tool is also supported in all Responses API compatible SDKs. The Vercel AI SDK does not yet expose the image generation tool.16This tool is also supported in all Responses API compatible SDKs. The Vercel AI SDK does not yet expose the image generation tool.

16 17 

17## Basic usage18## Basic usage

18 19 

19Add `image_generation` to `tools` and ask for an image. In the Responses API, each image arrives as an `image_generation_call` output item whose `result` field carries the base64-encoded image with no data-URL prefix, so you can decode it directly.20Add `image_generation` to `tools` and ask for an image. In the xAI SDK, each generated image is exposed on `response.image_outputs` as decoded bytes you can write straight to a file. In the Responses API, each image arrives as an `image_generation_call` output item whose `result` field carries the base64-encoded image with no data-URL prefix, so you can decode it directly.

20 21 

21```bash customLanguage="bash"22```bash customLanguage="bash"

22curl https://api.x.ai/v1/responses \23curl https://api.x.ai/v1/responses \


34 | base64 --decode > corgi_surfing.jpg35 | base64 --decode > corgi_surfing.jpg

35```36```

36 37 

38```python customLanguage="pythonXAI"

39import os

40 

41from xai_sdk import Client

42from xai_sdk.chat import user

43from xai_sdk.tools import image_generation

44 

45client = Client(api_key=os.getenv("XAI_API_KEY"))

46 

47chat = client.chat.create(

48 model="grok-4.6",

49 tools=[image_generation()],

50)

51chat.append(user("Generate an image of a corgi surfing a big wave, in the style of a Japanese woodblock print"))

52response = chat.sample()

53 

54print(response.content)

55with open("image.jpeg", "wb") as f:

56 f.write(response.image_outputs[0].image)

57```

58 

37```python customLanguage="pythonOpenAISDK"59```python customLanguage="pythonOpenAISDK"

38import base6460import base64

39import os61import os


156}'178}'

157```179```

158 180 

181```python customLanguage="pythonXAI"

182chat = client.chat.create(

183 model="grok-4.6",

184 tools=[image_generation(action="generate")],

185)

186chat.append(user("Generate an image of a hot air balloon over the desert"))

187response = chat.sample()

188```

189 

159```python customLanguage="pythonOpenAISDK"190```python customLanguage="pythonOpenAISDK"

160response = client.responses.create(191response = client.responses.create(

161 model="grok-4.6",192 model="grok-4.6",


198}'229}'

199```230```

200 231 

232```python customLanguage="pythonXAI"

233import os

234 

235from xai_sdk import Client

236from xai_sdk.chat import image, user

237from xai_sdk.tools import image_generation

238 

239client = Client(api_key=os.getenv("XAI_API_KEY"))

240 

241chat = client.chat.create(

242 model="grok-4.6",

243 tools=[image_generation(action="edit")],

244)

245chat.append(

246 user(

247 "Edit this image so it looks like a watercolor painting.",

248 image("https://docs.x.ai/assets/api-examples/images/style-realistic.png"),

249 )

250)

251response = chat.sample()

252 

253with open("image.jpeg", "wb") as f:

254 f.write(response.image_outputs[0].image)

255```

256 

201```python customLanguage="pythonOpenAISDK"257```python customLanguage="pythonOpenAISDK"

202import base64258import base64

203import os259import os


242 298 

243## Multi-turn editing299## Multi-turn editing

244 300 

245Images generated on a previous turn stay editable on follow-up turns. Continue the conversation with `previous_response_id`, and the model can refine its earlier images by reference:301Images generated on a previous turn stay editable on follow-up turns. Continue the conversation append the previous response to the chat in the xAI SDK, or pass `previous_response_id` in the Responses API — and the model can refine its earlier images by reference:

302 

303```python customLanguage="pythonXAI"

304import os

305 

306from xai_sdk import Client

307from xai_sdk.chat import user

308from xai_sdk.tools import image_generation

309 

310client = Client(api_key=os.getenv("XAI_API_KEY"))

311 

312chat = client.chat.create(

313 model="grok-4.6",

314 tools=[image_generation()],

315)

316 

317# Turn 1: generate an image

318chat.append(user("Generate an image of a lighthouse on a rocky coast"))

319response = chat.sample()

320with open("image.jpeg", "wb") as f:

321 f.write(response.image_outputs[0].image)

322 

323# Turn 2: edit the image from the previous turn

324chat.append(response)

325chat.append(user("Make it night time with a full moon"))

326followup = chat.sample()

327with open("edited_image.jpeg", "wb") as f:

328 f.write(followup.image_outputs[0].image)

329```

246 330 

247```python customLanguage="pythonOpenAISDK"331```python customLanguage="pythonOpenAISDK"

248import base64332import base64


315 | base64 --decode > champions_poster.jpg399 | base64 --decode > champions_poster.jpg

316```400```

317 401 

402```python customLanguage="pythonXAI"

403import os

404 

405from xai_sdk import Client

406from xai_sdk.chat import user

407from xai_sdk.tools import image_generation, web_search

408 

409client = Client(api_key=os.getenv("XAI_API_KEY"))

410 

411chat = client.chat.create(

412 model="grok-4.6",

413 tools=[web_search(), image_generation()],

414)

415chat.append(

416 user(

417 "Find out which team won the most recent FIFA World Cup, then generate an "

418 "image of a celebratory poster for that team, in a vintage travel-poster style."

419 )

420)

421response = chat.sample()

422 

423print(response.content)

424with open("image.jpeg", "wb") as f:

425 f.write(response.image_outputs[0].image)

426 

427# Per-tool invocation counts for the request

428print(response.server_side_tool_usage)

429```

430 

318```python customLanguage="pythonOpenAISDK"431```python customLanguage="pythonOpenAISDK"

319import base64432import base64

320import os433import os


357 470 

358When streaming, each image generation call emits progress events—`in_progress`, then `generating`, then `completed`—followed by a `response.output_item.done` event whose item carries the base64 result. Partial image previews are not emitted.471When streaming, each image generation call emits progress events—`in_progress`, then `generating`, then `completed`—followed by a `response.output_item.done` event whose item carries the base64 result. Partial image previews are not emitted.

359 472 

473In the xAI SDK, pass `include=["verbose_streaming"]` to watch tool calls as they happen; the decoded images are available on the accumulated response via `response.image_outputs` once the stream ends.

474 

475```python customLanguage="pythonXAI"

476import os

477 

478from xai_sdk import Client

479from xai_sdk.chat import user

480from xai_sdk.tools import get_tool_call_type, image_generation

481 

482client = Client(api_key=os.getenv("XAI_API_KEY"))

483 

484chat = client.chat.create(

485 model="grok-4.6",

486 tools=[image_generation()],

487 include=["verbose_streaming"],

488)

489chat.append(user("Generate an image of an origami fox in a paper forest"))

490 

491for response, chunk in chat.stream():

492 for tool_call in chunk.tool_calls:

493 if get_tool_call_type(tool_call) == "image_generation_tool":

494 print(f"\nGenerating image: {tool_call.function.arguments}")

495 if chunk.content:

496 print(chunk.content, end="", flush=True)

497 

498# The accumulated response carries the decoded images once the stream ends

499with open("image.jpeg", "wb") as f:

500 f.write(response.image_outputs[0].image)

501```

502 

360```python customLanguage="pythonOpenAISDK"503```python customLanguage="pythonOpenAISDK"

361import base64504import base64

362import os505import os