# Fallbacks

Automatic model fallback when the primary model fails

SilentAPI tries another route when the selected route fails. Enable cross-model fallbacks to try selected text models after a retryable error.

## How It Works

- Request a model, for example `gpt-6.1-terra`.

- If the model returns a retryable error, SilentAPI tries the next model.

- The `silentapi` object names the model that served the request.

- If every fallback fails, SilentAPI returns the last error.

## Checking If Fallback Was Used

Every response includes a `silentapi` object:

```
"silentapi": {
    "cost": 0.000045,
    "fallback": "claude-sonnet-5.5",
    "model": "claude-sonnet-5.5",
    "model_name": "Claude Sonnet 5.5",
    "requested_model": "gpt-6.1-terra",
    "substituted": true,
    "notice": "GPT 6.1 Terra was unavailable, so SilentAPI served this request with Claude Sonnet 5.5."
}
```

| Field | Type | Meaning |
| --- | --- | --- |
| cost | number | Charge in credits for the model that served the request |
| fallback | string or null | ID of the fallback model that served the request, or `null` |
| model | string | ID of the model that served the request |
| model_name | string | Name of the model that served the request |
| requested_model | string | Requested model ID. Only present when another model served the request. |
| substituted | boolean | `true`. Only present when another model served the request. |
| notice | string | Short text about the change. Only present when another model served the request. |

## Eligible Error Codes

Fallback is triggered when the requested model returns one of these status codes:

| Status | Reason |
| --- | --- |
| 401 | Authentication error (key rotation) |
| 402 | Service payment or quota error |
| 403 | Forbidden (key issue) |
| 404 | Requested model unavailable on that route |
| 408 | Request timeout |
| 409 | Conflict |
| 425 | Too early |
| 429 | Rate limited |
| 500+ | Server errors |
| Timeout | The model did not respond in time |

A request that reaches its time limit does not fall back, it ends with a `504` error.

## Custom Fallback Models

Configure a cross-model fallback chain on the [Fallbacks page](https://silentapi.com/fallbacks). SilentAPI retries the request on the selected models after a retryable error.

You can set up to two preferred fallback models. SilentAPI tries the primary model first and then the selected fallback models, and if you select none, it uses the account defaults.

Cross-model fallbacks are disabled by default. Turn on `Enable cross-model fallbacks`, select models, and save. Fallbacks follow retryable service errors only, so invalid requests such as 400 and 422, and errors about your key or balance, do not trigger them.

## Streaming and Fallbacks

SilentAPI selects the first available route before a stream starts. After the stream starts to send data, SilentAPI cannot retry the request with a different model. If you need fallbacks after output starts, do not set `stream: true`.

Source: https://silentapi.com/docs/fallbacks
