API Reference
Overview
The xAI REST API is compatible with the OpenAI REST API. This reference is generated from the OpenAPI specification and organised by resource.
Base URLs and authentication
| API | Base URL | Authenticate with |
|---|---|---|
| Inference (responses, chat completions, embeddings, images, videos, voice, files, batches, models) | https://api.x.ai | Authorization: Bearer <xAI API key> |
| Collections management | https://management-api.x.ai | Authorization: Bearer <xAI Management API key> |
| Collections search | https://api.x.ai | Authorization: Bearer <xAI API key> |
| Management (API keys, teams, billing, audit) | https://management-api.x.ai | Authorization: Bearer <xAI Management API key> |
API keys are created on the API Keys page of the xAI Console. Management keys are created on the Management Keys page; see Using Management API.
Inference API
- Responses
- Chat Completions
- Embeddings
- Images
- Videos
- Voice
- Files
- Batches
- Models
- Account
- Legacy & Deprecated
Management-key APIs
Other protocols
For status codes and their likely causes, see Debugging Errors.
Last updated: September 2, 2026