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}


Deprecated: The Anthropic SDK compatibility is fully deprecated. Please migrate to the Responses API or gRPC.


Image generations

/v1/images/generations


Image edits

/v1/images/edits


Video generations

/v1/videos/generations


Video edits

/v1/videos/edits


Get video generation results

/v1/videos/{request_id}


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}



List batches

/v1/batches


Get batch

/v1/batches/{batch_id}


List batch requests in a batch

/v1/batches/{batch_id}/requests


Add batch requests to a batch

/v1/batches/{batch_id}/requests


Get processing results of a batch

/v1/batches/{batch_id}/results


Cancel processing on a batch

/v1/batches/{batch_id}:cancel


Completions (legacy)

/v1/completions


Deprecated: The Anthropic SDK compatibility is fully deprecated. Please migrate to the Responses API or gRPC.