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

# Error Codes

> HTTP status codes vs. business error codes, and how to debug

Error responses are JSON, shaped like:

```json theme={null}
{ "error": { "message": "...", "type": "...", "code": "invalid_request" } }
```

## HTTP status codes

| Status | Meaning                  | Common cause                                           |
| ------ | ------------------------ | ------------------------------------------------------ |
| 400    | Bad request              | Missing / malformed parameters                         |
| 401    | Unauthorized             | Missing or wrong key                                   |
| 403    | Forbidden                | Key revoked / no access to the model                   |
| 404    | Not found                | Path or model does not exist                           |
| 429    | Rate limited             | See [Rate Limits](/en/api-reference/guide/rate-limits) |
| 5xx    | Upstream / gateway error | Retry or contact support                               |

## Business error codes

Possible values of the `error.code` field:

| code                             | Meaning                          | What to do                            |
| -------------------------------- | -------------------------------- | ------------------------------------- |
| `invalid_request`                | Invalid request parameters       | Check params and body                 |
| `bad_request_body`               | Malformed request body           | Verify the JSON is valid              |
| `read_request_body_failed`       | Failed to read request body      | Check body and Content-Type           |
| `convert_request_failed`         | Request conversion failed        | Ensure params match the API format    |
| `sensitive_words_detected`       | Sensitive content detected       | Adjust the input                      |
| `prompt_blocked`                 | Prompt was blocked               | Adjust the prompt                     |
| `access_denied`                  | Access denied                    | Check key, permissions, and group     |
| `model_not_found`                | Model not found                  | Verify `model` and your plan's models |
| `invalid_api_type`               | Unsupported API type             | Use a supported API format            |
| `get_channel_failed`             | No available channel             | Retry later or contact support        |
| `channel:no_available_key`       | No available channel key         | Retry later or contact support        |
| `channel:invalid_key`            | Invalid channel key              | Contact support                       |
| `channel:model_mapped_error`     | Model mapping error              | Contact support                       |
| `channel:response_time_exceeded` | Upstream timeout                 | Retry; shrink the request if needed   |
| `insufficient_user_quota`        | Insufficient quota               | Top up or check your plan quota       |
| `pre_consume_token_quota_failed` | Quota pre-deduction failed       | Check quota and retry                 |
| `model_price_error`              | Model pricing error              | Contact support                       |
| `count_token_failed`             | Token counting failed            | Check input and retry                 |
| `do_request_failed`              | Upstream request failed          | Retry                                 |
| `bad_response`                   | Bad upstream response            | Retry or contact support              |
| `bad_response_status_code`       | Bad upstream status code         | Retry or contact support              |
| `empty_response`                 | Empty upstream response          | Retry; raise timeout for streaming    |
| `read_response_body_failed`      | Failed to read upstream response | Retry                                 |
| `json_marshal_failed`            | Serialization failed             | Retry or contact support              |
| `query_data_error`               | Data query error                 | Retry or contact support              |
| `update_data_error`              | Data write error                 | Retry or contact support              |
