REST API Reference
The xAI Enterprise API is a robust, high-performance RESTful interface designed for seamless integration into existing systems. It offers advanced AI capabilities with full compatibility with the OpenAI REST API.
The base for all routes is at https://api.x.ai. For all routes, you have to authenticate with the header Authorization: Bearer <your xAI API key>.
Chat completions
/v1/chat/completions
Create new response
/v1/responses
Retrieve previous response
/v1/responses/{response_id}
Delete previous response
/v1/responses/{response_id}
Messages (Anthropic compatible)
/v1/messages
Image generations
/v1/images/generations
API key
/v1/api-key
List models
/v1/models
Get model
/v1/models/{model_id}
List language models
/v1/language-models
Get language model
/v1/language-models/{model_id}
List image generation models
/v1/image-generation-models
Get image generation model
/v1/image-generation-models/{model_id}
Tokenize text
/v1/tokenize-text
Get deferred chat completions
/v1/chat/deferred-completion/{request_id}
Completions (legacy)
/v1/completions
Completions (Anthropic compatible - legacy)
/v1/complete