---
title: "Error handling"
description: "When to retry, and when to stop."
---

# Error handling

Every status, body and cause is on [Errors](../api/errors.md). This page says what a client should do.

| Status | Retry? |
|---|---|
| 400, 401, 404, 413 | No. Fix the request or the key. |
| 402 | No. Top up, or raise the key's spend limit. |
| 408, 502 | Yes, with backoff: wait 1 second, then 2, then 4. |
| 429 | Yes, after `Retry-After` seconds when the header is present; otherwise with backoff. |
| 500, 503 | Yes, after a few seconds. |

The gateway already tries the model's other hosts before it answers 408, 429, or a 502 for a failed host; see [Rate limits](rate-limits.md). With **Allow fallbacks** off in your [account settings](../routing/provider-routing.md#account-settings), it tries one host per model.
To try other models too, list them in `models`; see [Model fallbacks](../routing/model-fallbacks.md).
