---
title: "API error codes & retries: handling 401, 429 and 502 | MYUSAPI"
description: "The error format for each protocol, what every code means and how to fix it, and which errors are worth retrying with backoff."
url: https://myusapi.com/en/docs/errors
---

# Error handling

## Error shapes

Gateway errors use {"error": {"code": "..."}}. Errors from upstream keep the native shape of the protocol you called: {"type": "error", "error": {...}} for Messages, {"error": {"type", "message"}} for OpenAI, and {"error": {"code", "message", "status"}} for Gemini.

| Status & code | Meaning & fix |
| --- | --- |
| 400 invalid_request Gateway | The body is not valid JSON or a field is invalid. Check the JSON and send Content-Type: application/json. |
| 400 request_not_covered Gateway | This key does not accept something in the request: a built-in tool such as web search on Responses or Chat, background mode, or non-text output. The response message says which. Remove what the message names. The same request will not succeed on retry. |
| 401 invalid_api_key Gateway | The key is missing, malformed, or a demo_ key. Send a real key: Authorization: Bearer <KEY>. |
| 401 INVALID_API_KEY / API_KEY_DISABLED Upstream | The key does not exist or is disabled. Check the key in your workspace or create a new one. |
| 403 https_required Gateway | The request used plain http://. The gateway does not process or forward it. With Always Use HTTPS enabled the site may instead redirect it to https://; either way the key was already sent in cleartext. Use an https:// base URL, and rotate any key already sent over http://. |
| 403 model_not_allowed Gateway | This model is not enabled on this site. Call GET /v1/models for the IDs you can use. |
| 403 INSUFFICIENT_BALANCE Upstream | Your balance is exhausted. Top up and retry. If a provider issued your key, contact them. |
| 403 API_KEY_EXPIRED / GROUP_NOT_ALLOWED Upstream | The key has expired or its group is unavailable. Create a new key or choose another group. |
| 404 route_not_found Gateway | The path is not a public endpoint. OpenAI-compatible clients need /v1 at the end of the base URL; clients that add /v1 themselves, such as Claude Code, work with or without it. Then check the path and method against the API reference. |
| 413 body_too_large Gateway | The body is larger than 32 MB. Trim the context or use caching. |
| 429 rate_limited Gateway | Too many requests per minute from one IP. Back off and retry after Retry-After. |
| 429 API_KEY_QUOTA_EXHAUSTED / rate_limit_exceeded Upstream | The key quota is used up, or a key or group rate limit was hit. Raise the key quota or back off per Retry-After. |
| 429 managed_credit_large_requests_busy Upstream | Too many large requests (over 4 MB each) are being handled at once. Retry after Retry-After, or compact the context. |
| 429 gateway_concurrency_limit Upstream | Too many concurrent requests. Lower concurrency and retry. |
| 502 upstream_error Upstream | The upstream provider rejected the request or failed. Retry later; if it persists, contact support with x-request-id. |
| 503 inference_not_configured Gateway | This site does not serve inference right now. Check the status page for availability. |
| 503 overloaded_error Upstream | Upstream is overloaded or no account is available. Retry with exponential backoff or switch to a similar model. |

## Retrying

Retry only 429, 502, and 503, with exponential backoff that honours Retry-After. 400, 401, and 403 are terminal and will not succeed on retry. Include x-request-id when reporting an issue.

Service availability Accounts and key delivery live in your workspace (/workspace). Available endpoints and models depend on current service status and account access. Top up in US dollars by card, or by Alipay or WeChat Pay where the checkout lists them; if you already hold USDC, you can use native USDC on Solana. [View service status](https://myusapi.com/en/status)
