gRPC API Reference
The xAI gRPC API is a robust, high-performance gRPC interface designed for seamless integration into existing systems.
The base url for all services is at api.x.ai. For all services, you have to authenticate with the header Authorization: Bearer <your xAI API key>.
Visit xAI API Protobuf Definitions to view and download our protobuf definitions.
Chat
xai_api.Chat
An API that exposes our language models via a Chat interface.
Methods of xai_api.Chat
GetCompletion
unary
Samples a response from the model and blocks until the response has been fully generated.
GetCompletionChunk
server streaming
Samples a response from the model and streams out the model tokens as they are being generated.
StartDeferredCompletion
unary
Starts sampling of the model and immediately returns a response containing a request id. The request id may be used to poll the `GetDeferredCompletion` RPC.
GetDeferredCompletion
unary
Gets the result of a deferred completion started by calling `StartDeferredCompletion`.
GetStoredCompletion
unary
Retrieve a stored response using the response ID.
DeleteStoredCompletion
unary
Delete a stored response using the response ID.
Image
xai_api.Image
An API service for interaction with image generation models.
Methods of xai_api.Image
GenerateImage
unary
Create an image based on a text prompt and optionally another image.
Batch Management
xai_api.BatchMgmt
An API service for processing batch requests asynchronously at lower priority than chat service.
Methods of xai_api.BatchMgmt
CreateBatch
unary
Creates a new batch.
GetBatch
unary
Retrieves an individual batch.
ListBatches
unary
Retrieves a list of all batches owned by the team.
CancelBatch
unary
Stops processing of all outstanding requests in the batch.
AddBatchRequests
unary
Adds requests to a batch.
ListBatchRequestMetadata
unary
Lists metadata about individual requests in a batch.
ListBatchResults
unary
Lists processing results of a batch.
GetBatchRequestResult
unary
Retrieves an individual request in a batch.
Models
xai_api.Models
An API service that let users get details of available models on the platform.
Methods of xai_api.Models
ListLanguageModels
unary
Lists all language models available to your team (based on the API key).
ListEmbeddingModels
unary
Lists all embedding models available to your team (based on the API key).
ListImageGenerationModels
unary
Lists all image generation models available to your team (based on the API key).
GetLanguageModel
unary
Get details of a specific language model by model name.
GetEmbeddingModel
unary
Get details of a specific embedding model by model name.
GetImageGenerationModel
unary
Get details of a specific image generation model by model name.
Auth Service
xai_api.Auth
An API service to check status of an API key.
Methods of xai_api.Auth
get_api_key_info
unary
Returns some information about an API key.
Raw Sampling of a Language Model
xai_api.Sample
An API service for sampling the responses of available language models.
Methods of xai_api.Sample
SampleText
unary
Get raw sampling of text response from the model inference.
SampleTextStreaming
server streaming
Get streaming raw sampling of text response from the model inference.
Did you find this page helpful?