Skip to main content
Most models are served by several providers. For each request the Gateway keeps the providers your rules allow, ranks them, and calls the best one. If that provider fails, it tries the next; if every provider fails with a retryable error, it can move on to a fallback model. Your client should still retry 429 and 5xx responses with exponential backoff.

Choose how providers are ranked

Set the workspace default in Dashboard -> Settings -> Routing, with phaseo settings update --routing-mode <mode>, or with routing_mode on PATCH /v1/settings. For one request, send provider.sort or routing.mode, or add a suffix to the model ID: A suffix overrides routing.mode, provider.sort, and preset and workspace modes. Allow lists, regions, guardrails and price ceilings still apply. The Routing settings page also has beta and alpha channel toggles, so preview providers only get traffic when you opt in.

How balanced mode ranks providers

For text requests (Chat Completions, Responses and Messages), balanced estimates each provider’s cost per successful answer:
  • Tokens: what a typical request for this model costs on the provider, using the model’s measured prompt and output sizes and the provider’s measured cache-hit rate.
  • Waiting: the time to first token and to the full response, converted to dollars at the model’s typical price per second.
  • Failures: the total divided by the provider’s recent success rate, plus a penalty for provider errors and a smaller one for rate limits.
Providers close to the lowest cost share most of the traffic. Every provider keeps a small share, so a recovery is noticed. Pick a scenario to see how it plays out (the providers are examples): Other endpoints are scored on reliability, latency, tail latency, throughput, price and token fit. If you’re a provider, How Providers Earn Traffic shows how to win a larger share.

Request-level model fallbacks

List fallback models in models. Phaseo tries model first, then each entry in order:
Choose what each model returns to see when Phaseo moves on: What moves to the next model. A model is tried only after the previous one, with all its provider retries, ends in 429, 500, 502, 503 or 504. A 429 from a Phaseo budget or free-model quota also moves on, since another model may fit the remaining limit. So does a model that no provider serves any more, for example a retired one. What doesn’t. Client errors such as 400, 401, 402, 403, 404, 408, 413 and 422 return immediately. So do failures before the first model runs, such as authentication or API key rate limits. Rules for the list:
  • model is required; sending models alone returns 400.
  • models takes 1 to 25 entries. Duplicates and copies of model are ignored.
  • Entries can be model IDs, provider-qualified IDs or presets such as @support.
  • Each attempt is validated as its own request (endpoint, parameters, workspace models, guardrails, presets, pricing, BYOK). A fallback that can’t serve the request is skipped and logged; it never replaces the error you’d otherwise get. An attempt identical to one already made is skipped too.
Logs and billing. Each attempt is a separate request with its own usage record, billed as if fallbacks didn’t exist. The response model field names the model that answered, and its routing trace lists the primary request ID, the fallback order and each earlier attempt. Streaming, video and music. A stream falls back only before its first byte; after that, errors arrive in the stream. Video and music fall back only while the job is being submitted. With other routing controls. Fallbacks on an attached dynamic route take precedence over models, and a fixed model chosen by the route still applies to each attempt. A preset applies its own constraints to each attempt it’s used in. phaseo/auto manages its own fallbacks and can’t be combined with models. Multipart endpoints accept repeated models fields, models[] fields, or one JSON array string. See also Rate limits and Errors.

Pin one provider

Put the provider in front of the model ID to use exactly that provider:
This turns off cross-provider fallback for the request. Suffixes stay part of the model ID, as in baseten:google/gemma-4-26b-a4b:free. Provider-qualified model IDs covers the full syntax and errors.

Limit which providers are used

Attach routing rules to API keys

A dynamic route is a flow of rules attached to one or more inference API keys. It can:
  • branch on request-body fields, headers, custom metadata, endpoint, model or session ID
  • split traffic by percentage for A/B tests and rollouts
  • cap daily, weekly or monthly requests or cost per key
  • switch model, routing mode, provider preference and fallback models (up to eight)
  • turn on cache-aware and session-aware provider affinity
Conditions have true and false outputs; rate and budget nodes have within and exceeded outputs. Percentage splits are deterministic per session or prompt-cache key, so a cached conversation doesn’t move between branches. Saving creates an immutable draft version. Deploying copies that version to the Gateway and clears policy caches for its keys; earlier versions stay available for rollback. Provider-health recommendations appear under Insights. From a script, use the /v1/routing/dynamic-routes API with a management key. Custom metadata goes in the request body on the OpenAI-compatible text endpoints:

Keep a conversation on one provider

Cache-aware routing is on by default for text generation. A request that sends prompt_cache_key or session_id, or opts into caching with cache_control (top-level, in provider_options.anthropic, or as a cache_control or prompt_cache_breakpoint mark on a message block or tool), is pinned to the provider and route that served its first successful request. Other requests are pinned for 15 minutes once a provider reports a cache read or write for the same opening context, if that provider’s cached input is cheaper than its standard input. Turn it off for one request with provider.cache_aware_routing: false, or keep cache affinity but ignore the session with routing.session_affinity: false:
Provider affinity lists the hints Phaseo sends to each provider.

Explain a routing decision

Open Dashboard -> Settings -> Usage -> Request logs, select a request, and expand Routing observability under Provider Responses. It shows:
  • every ranked provider with its final score, and which were selected and attempted
  • providers excluded before ranking, with the reason
  • providers deranked by their rollout or routing status
  • each score’s inputs, weights, contributions and multipliers
Score factors change the score; recorded context explains the decision without necessarily affecting it. Traces hold numbers and statuses only, never prompts or output. Requests made before routing observability was enabled may show a partial trace or none.

What counts against a provider’s uptime

Geographic restrictions and rate limits are tracked separately, because they don’t mean the provider is down. For production, log request IDs, status codes and model IDs so you can match failures to these traces.

Retired models

A retired model keeps working while any provider still serves it. After that, requests fail with 410 model_retired, unless the workspace sends them to a replacement with retired model routing. Your own models list is always tried first. See Model Deprecation and Retirement.

BYOK considerations

With , Phaseo routes and logs the request while your provider bills the model usage. Scope each key to the models and API keys that need it. To stop a failed BYOK request from retrying on Phaseo credits, turn off fallback in Dashboard -> Settings -> BYOK, or set byok_fallback_enabled on PATCH /v1/settings with a management key. Add keys in the same place, or with POST /v1/byok and a management key.
Last modified on November 7, 2026