#### 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](https://status.x.ai) for the latest updates. The status is also available
> via RSS at [https://status.x.ai/feed.xml](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](/developers/rest-api-reference).

## Status Codes

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

### 4XX Status Codes

| Status                                                                                  | Endpoints                   | Cause                                                                                                                                                                               | Solution                                                                                                                  |
| --------------------------------------------------------------------------------------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **400**Bad Request            | All endpoints               |  | Check your request body or request URL.                                                                                   |
| **401**Unauthorized           | All endpoints               | No 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](https://console.x.ai). |
| **403**Forbidden              | All endpoints               |                                                       | Ask your team admin for permission.                                                                                       |
| **404**Not Found              | All endpoints               |                                                    | Check your request body and endpoint URL against the [API Reference](/developers/rest-api-reference).                     |
| **405**Method Not Allowed     | All endpoints               | The 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](/developers/rest-api-reference).                                    |
| **415**Unsupported Media Type | Endpoints supporting `POST` |                                                              |                       |
| **422**Unprocessable Entity   | Endpoints supporting `POST` | A field in the `POST` request body has an invalid format.                                                                                                                           | Check your request body against the [API Reference](/developers/rest-api-reference).                                      |
| **429**Too Many Requests      | Inference endpoints         | You are sending requests too frequently and have reached the rate limit.                                                                                                            | Reduce your request rate or increase your rate limit on [xAI Console](https://console.x.ai).                              |

### 2XX Status Codes

| Status                                                                    | Endpoints                                   | Cause                                                                                                  | Solution                                   |
| ------------------------------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------ |
| **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](mailto:support@x.ai?subject=API%20Bug%20Report) 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](https://discord.gg/x-ai).
