> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trustqai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

> Error responses, what they mean and what to do.

When a request fails, the Qai Platform API returns a non-2xx HTTP status and a JSON body describing the problem, in the same format as the OpenAI API.

## Error format

```json theme={null}
{
  "error": {
    "type": "invalid_request_error",
    "code": "model_access_denied",
    "message": "requested model is not available for this API key",
    "param": null
  }
}
```

* `type` is the broad category.
* `code` names the specific problem where there is one, otherwise it is `null`.
* `message` is a human-readable description. Do not parse it; branch on `type` and `code`.

## Common errors

| Status | Type | Code | Meaning | What to do |
| - | - | - | - | - |
| `400` | `invalid_request_error` | `model_access_denied` | The model is not offered, or your key is not allowed to use it | Check the model name with [GET /models](https://docs.trustqai.com/api-reference/list-models.md) |
| `400` | `invalid_request_error` | | The request body is malformed or missing a required field | Fix the request |
| `401` | `authentication_error` | | The key is missing, wrong, expired or revoked | Check the key; a new key can take up to a minute to work |
| `429` | `rate_limit_error` | `budget_exceeded` | Your credit has run out | [Add credit](https://docs.trustqai.com/platform/credit.md#add-credit) |
| `5xx` | `provider_error` or `internal_error` | | The model or the service had a problem | Retry with backoff; if it persists, ask in the [Qai Discord](https://discord.gg/T34HuPHMRa) |

## Retrying

Retry `5xx` responses with exponential backoff. Do not retry `400` or `401` unchanged: they fail the same way until the request or key is fixed. A `429` with `budget_exceeded` succeeds again only after credit is added.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.