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

# Routing and failover

> Understand how the gateway serves your chosen model, handles failed routes, and bills BYOK fallbacks.

Choose a model ID, such as `anthropic/claude-sonnet-4-5`. The gateway handles its serving routes. A model's creator prefix and the provider that serves the request can differ.

For paid routes, you pay the model's published rate regardless of which backend serves it. See the actual provider and cost in [request logs](/docs/request-logs).

## When a route fails

For text generation, the gateway can try another configured route for the **same model**. It does not choose a different model for you.

| When the failure happens                                | What to expect                                                     |
| ------------------------------------------------------- | ------------------------------------------------------------------ |
| Before a complete non-streaming response                | Another available route can be tried.                              |
| Before any content in a stream                          | Another available route can be tried.                              |
| After text, reasoning, or tool content starts streaming | The stream reports the failure and closes. No transparent restart. |
| No route succeeds                                       | The request fails; use the error and logs to diagnose it.          |

A model may have only one available route. Failover does not guarantee success. If your application needs a different fallback model, implement that decision in the application and check that it supports the same inputs and tools.

## With your own provider keys

A matching BYOK credential replaces the gateway credential for that route. Other configured routes may still use gateway credentials.

<Warning>
  Adding a BYOK key does not guarantee every request uses it. A request served by a paid fallback consumes gateway credits. If any resolved route is paid, the request must pass the balance check before generation; zero-balance use requires all resolved routes to be BYOK.
</Warning>

See [BYOK setup and precedence](/docs/byok#routing-precedence) for credential mappings. Revoking a credential can make matching requests use paid gateway routes again.

## Before adding retries

The gateway already retries and fails over eligible text requests. Extra client retries can multiply latency and work. Use a small retry budget, backoff with jitter, and an overall timeout. Treat partial streamed output as incomplete, and avoid replaying application tools with side effects.

Use [error handling](/docs/errors#retries-and-rate-limits) for retry decisions. Routing fields from other gateways do not configure impossibl's routes.
