RoutingRouting overview
Routing overview
How the gateway picks one EU provider per request — and what you can override.
For models hosted by more than one EU provider, the gateway picks exactly one per request. You can stay hands-off (the gateway's defaults are sane), give a strategy hint, or take total control with provider pinning.
The five-step decision
flowchart TD
Req[Request arrives] --> Pin{X-CleverRouter-Provider set?}
Pin -- yes --> CheckHost{Does that provider<br/>host this model?}
CheckHost -- no --> Err400[400 provider_unsupported]
CheckHost -- yes --> UsePin[Use pinned provider]
Pin -- no --> Sort[Sort by model_providers.priority ASC]
Sort --> Health{Provider healthy<br/>in last probe?}
Health -- no --> NextProvider[Skip, try next]
Health -- yes --> Disabled{enabled = true AND<br/>deprecated_at IS NULL?}
Disabled -- no --> NextProvider
Disabled -- yes --> Use[Use provider]
NextProvider --> HealthWord version:
- Explicit pin (
X-CleverRouter-Provider) wins if the model is hosted there. If not:400 provider_unsupported— no silent fallback. - Priority sort on
model_providers.priorityASC — lowest wins. - Health filter — providers that were
downin the last health probe are skipped (unless all are down). - Disabled / deprecated —
enabled=falsemappings are ignored.deprecated_at IS NOT NULLreturns410 Gone. - Strategy hint (
X-CleverRouter-Strategy) refines step 2 when multiple providers tie on priority.
What we deliberately don't do
| Feature | Why not yet |
|---|---|
| Cost-based dynamic routing | Hard to reason about — predictable beats clever |
| Latency-based dynamic routing | Same — operators want repeatable bills |
| Sticky sessions | Statelessness is easier to scale |
| Cross-border failover | Invariant — would break EU-only positioning |
Inspecting the chosen provider
Every successful response carries:
X-CleverRouter-Provider: scaleway
X-Request-Id: 0193adc8-…Combine the two and you can correlate any call with the dashboard's request log.
Streaming and failover
Once the stream starts, no failover
The gateway can't replay a streaming response on a different
provider once the first chunk has shipped. Failover for streams
works only before the first byte leaves. For non-stream
requests, a 5xx triggers the next eligible provider
automatically.
Three sections that follow this
- Strategies — what
cheapest/fastest/bestactually mean. - Provider pinning — when to take control and how.
- Retry & timeout —
429/5xxpolicy,CRTimeoutError.