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.

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
400
Bad Request
All endpoints
  • A POST request body specified an invalid argument, or a GET request with a dynamic route has an invalid URL param.
  • An incorrect API key was supplied.
Check your request body or request URL.
401
Unauthorized
All 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.
403
Forbidden
All endpoints
  • Your API key or team doesn't have permission to perform the action.
  • Your API key or team is blocked.
Ask your team admin for permission.
404
Not Found
All endpoints
  • A model specified in a POST request body was not found.
  • The endpoint URL is invalid (misspelled URL).
Check your request body and endpoint URL against the API Reference.
405
Method Not Allowed
All 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.
415
Unsupported Media Type
Endpoints supporting POST
  • The POST request has an empty body.
  • The Content-Type: application/json header is missing.
  • Add a valid request body.
  • Set the Content-Type: application/json header.
422
Unprocessable Entity
Endpoints supporting POSTA field in the POST request body has an invalid format.Check your request body against the API Reference.
429
Too Many Requests
Inference 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
202
Accepted
/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.


Last updated: May 13, 2026