Official SpaceXAI API documentation. Build with Grok: chat, image and video generation, voice, tool calling, and structured outputs. Quickstarts, guides, and API reference.
ENDPOINTS
STRUCTURED FROM OPENAPI 3.1
GET
/v1/api-key
Get information about an API key, including name, status, permissions and users who created or modified this k
POST
/v1/chat/completions
Create a chat response from text/image chat prompts. This is the endpoint for making requests to chat and imag
GET
/v1/chat/deferred-completion/{request_id}
Tries to fetch a result for a previously-started deferred completion. Returns `200 Success` with the response
POST
/v1/complete
(Legacy - Not supported by reasoning models) Create a text completion response. This endpoint is compatible wi
POST
/v1/completions
(Legacy - Not supported by reasoning models) Create a text completion response for a given prompt. Replaced by
POST
/v1/documents/search
Search for content related to the query within the given collections.
GET
/v1/embedding-models
List all embedding models available to the authenticating API key with full information. Additional informatio
GET
/v1/embedding-models/{model_id}
Get full information about an embedding model with its model_id.
POST
/v1/embeddings
Create an embedding vector representation corresponding to the input text. This is the endpoint for making req
GET
/v1/files
List files owned by the authenticated team, paginated. The response
always returns a `pagination_token`; pass
POST
/v1/files
Upload a file to xAI's storage. Returns the file's metadata. Files can
be referenced by ID anywhere a `file_id
GET
/v1/files/{file_id}
Retrieve metadata for a single file by ID. Errors with 404 if the file
doesn't exist, has been deleted, or has