Skip to content

Getting Started

Debugging Errors

When you send a request, you would normally get a 200 OK response from the server with the expected response body. If there has been an error with your request, or error with our service, the API endpoint will typically return an error code with error message.

NOTE

If there is an ongoing service disruption, you can visit https://status.x.ai for the latest updates. The status is also available via RSS at https://status.x.ai/feed.xml.

The service status is also indicated in the navigation bar of this site.

Most of the errors will be accompanied by an error message that is self-explanatory. For typical status codes of each endpoint, visit API Reference.

Status Codes

Here is a list of potential errors and statuses arranged by status codes.

4XX Status Codes

StatusEndpointsCauseSolution
400Bad RequestAll endpointsCheck your request body or request URL.
401UnauthorizedAll endpointsNo authorization header or an invalid authorization token was provided.Supply an Authorization: Bearer <XAI_API_KEY> header. You can get a new API key on xAI Console.
403ForbiddenAll endpointsAsk your team admin for permission.
404Not FoundAll endpointsCheck your request body and endpoint URL against the API Reference.
405Method Not AllowedAll endpointsThe request method is not allowed. For example, sending a POST to an endpoint that only supports GET.Check your request method against the API Reference.
415Unsupported Media TypeEndpoints supporting POST
422Unprocessable EntityEndpoints supporting POSTA field in the POST request body has an invalid format.Check your request body against the API Reference.
429Too Many RequestsInference endpointsYou are sending requests too frequently and have reached the rate limit.Reduce your request rate or increase your rate limit on xAI Console.

2XX Status Codes

StatusEndpointsCauseSolution
202Accepted/v1/chat/deferred-completion/{request_id}Your deferred chat completion request is queued for processing, but the response is not yet available.Wait for the request to finish processing.

Bug Report

If you believe you have encountered a bug and would like to contribute to our development process, email API Bug Report to support@x.ai with your API request and response and relevant logs.

You can also chat in the #help channel of our xAI API Developer Discord.

💬