Choose a routing mode
Start withbalanced unless one production requirement clearly matters more than the others.
Configure the workspace default in Dashboard -> Settings -> Routing, with
phaseo settings update --routing-mode <mode>, or by sending routing_mode to PATCH /v1/settings. Use presets when one workflow needs a narrower provider or model policy than the workspace default.
Model routing suffixes
Append a routing suffix when the model ID itself should make the optimization mode authoritative for that request:
For example,
openai/gpt-5-mini:nitro uses throughput-first routing. A recognized routing suffix takes precedence over request-level routing.mode or provider.sort, preset and workspace routing modes. Other constraints such as provider allow lists, regional requirements, guardrails, and price ceilings still apply.
How routing works at a high level
- You send a request with a model id.
- The Gateway evaluates provider health, latency, and capability coverage.
- A provider is selected and the request is executed.
Select a model with the auto-router
Auto Routing is currently an Alpha available to selected workspaces. Usephaseo/auto when the model should change with the workload. Phaseo starts
from every eligible production text model, then applies workspace constraints
and builds a workload-specific shortlist:
- Open Dashboard -> Settings -> Routing -> Auto Routing.
- Choose whether to optimize for balanced performance, quality, cost, or latency.
- Select an Economy, Standard, Premium, or unrestricted spend profile. These profiles apply fixed input and output price ceilings before scoring.
- Optionally narrow eligible models with patterns such as
anthropic/*,openai/gpt-5.*, or an exact model ID. - Choose whether Phaseo may try the remaining ranked models after a retryable failure.
- Save the configuration.
phaseo routing auto update with --objective, --spend-profile, --allowed-patterns and --allow-fallbacks, or call PATCH /v1/routing/auto. phaseo routing auto get shows the current configuration.
Applications then opt in without copying workspace routing policy into every
request:
Spend profiles are hard standard-tier price ceilings in USD per million text
tokens:
Custom limits set the input and output ceilings directly. Models without known
standard text pricing are not included in the managed candidate universe.
For each
phaseo/auto request, Phaseo creates a normal child gateway request
to a pinned low-cost classifier model. The child request uses the same
workspace and billing identity, appears separately in request logs, and is
labelled with purpose=auto_routing_classifier and the parent request ID.
The classifier returns a structured workload mix, complexity score, and
confidence value; it never selects a model directly.
Hard request facts such as tools and structured output are included as trusted
metadata. If the classifier request fails, times out, or returns invalid data,
Phaseo falls back to the local deterministic code, reasoning, tool use,
structured output, translation, summarization, or general classifier rather
than failing the generation request.
Classifier complexity represents the minimum model capability likely to
produce a reliably acceptable answer. Phaseo applies a capability margin, then
combines benchmark fit with the workspace objective, price, latency, provider
health, and reliability. The classifier request and selected generation
request are metered independently through the normal gateway pipeline.
Before scoring, every allow-listed model must pass the normal endpoint,
workspace model, provider, privacy, guardrail, and circuit-breaker checks. The
router then combines relevant non-self-reported Phaseo catalogue benchmarks
with current Phaseo provider health, latency, and pricing. Missing benchmark or
operational data is neutral; it does not widen the allow-list.
The request’s limits on where its data may go apply to Auto too. When a
request sets provider.require_zero_data_retention: true, or the workspace or the
key’s guardrail allows only providers with zero data retention, the router
shortlists only models with a provider that offers it. Required regions are
checked against each candidate’s providers in the same way. The classifier
request carries the same limits, along with the only and ignore providers;
if the classifier model can’t meet them, Phaseo uses the local classifier
instead. When the request’s residency requirements are what leaves Auto no
model (every model it considered failed them), the request fails with
403 model_region_unavailable and unmet_requirements, the same error a fixed
model gets; if models were also ruled out for other reasons, it fails with
400 unsupported_model_or_endpoint.
The response model field identifies the selected model. Request details show
the workload, objective, selected model, fallback order, candidate scores,
factor scores, benchmark IDs, exclusions, and algorithm version. Routing traces
contain no prompt or response content.
If model fallbacks are enabled in the workspace, Phaseo retries the remaining ranked models on
429, 500, 502, 503, or 504. Each fallback passes the complete policy
and provider-selection pipeline again. Client errors do not switch models.
A fixed model selected by an attached dynamic route takes precedence. In that
case, request details record the override and auto-router model fallbacks are
disabled for the request.
Explain a routing decision
Open Dashboard -> Settings -> Usage -> Request logs, select a request, then expand Routing observability under Provider Responses. The request log shows:- every ranked provider and its final score
- the provider Phaseo selected and any providers it attempted
- providers excluded before ranking, with the recorded reason
- providers that were deranked by their rollout or routing status
- the score inputs, weights, contributions, and multipliers used for each ranked provider
balanced text requests (Chat Completions, Responses and Messages), Phaseo ranks eligible providers by their expected cost per successful answer. That cost adds what a typical request for the model costs on the provider, using the model’s measured prompt and output sizes and the provider’s measured cache-hit rate, to the time spent waiting for the first token and the full response. It is then divided by the provider’s recent success rate. Provider errors add a further penalty, and rate limits a smaller one. Providers close to the lowest cost share most of the traffic, and every provider keeps a small share so a recovery is noticed. To rank by price alone, send provider.sort: "price". Other endpoints are scored on reliability, latency, tail latency, throughput, price, and token fit. The displayed calculation shows how each factor contributed to the final score instead of presenting every recorded metric as equally important.
Pick a scenario to see how the cost per successful answer splits into tokens, waiting and failures, and how that sets each provider’s share of traffic. The providers are examples.
Reliability and provider uptime
The reliability sample is the value used by the score. It is calculated from provider outcomes; the success rate is shown as supporting context. These outcomes reduce provider uptime:- authentication failures (
401) - payment failures (
402) - model-not-found responses (
404) - server errors (
500and above) - errors after a response stream starts
- successful HTTP responses that finish with an error reason
- bad requests (
400) - geographic restrictions (
403) - oversized payloads (
413) - rate limits (
429)
Trace availability and privacy
Complete routing traces are available for requests made after routing observability was enabled. Older requests may show a partial trace or no routing details. Routing traces are bounded and content-free. They contain the numbers and statuses needed to explain provider selection, but do not copy prompts, messages, or generated content into the trace.Choose an exact provider in the model id
Use<provider-id>:<canonical-model-id> when a request must use one specific provider-model pair:
baseten:google/gemma-4-26b-a4b:free.
Read Provider-qualified model IDs for complete syntax, free-route validation, routing precedence, aliases, error codes, and request examples.
Control routing and fallbacks
The current public fallback and routing controls are intentionally explicit:Presets constrain the fallback pool
In Dashboard -> Settings -> Presets, you can define:- allowed models
- provider allow lists
- provider ignore lists
- default prompt and parameter behavior
Routing mode changes provider ranking
In Dashboard -> Settings -> Routing, workspaces can tune how the Gateway ranks compatible providers:balancedpricelatencythroughput
phaseo settings update --routing-mode <mode>.
The same page also exposes beta and alpha channel toggles so preview traffic can be introduced intentionally instead of appearing as an untracked routing side effect.
BYOK fallback is explicit
In Dashboard -> Settings -> BYOK, teams can choose whether a failed request is allowed to fall back to Phaseo credits. This is the current public control for the common “my own key failed, should the request still complete?” decision. Agents can set it withbyok_fallback_enabled on PATCH /v1/settings, for example phaseo settings update --body-json '{"byok_fallback_enabled":true}', and add provider keys with phaseo byok create --provider <id> --name <name> --key-stdin.
Dynamic routes attach policy to API keys
In Dashboard -> Settings -> Routing, create a dynamic route when different API keys or request classes need different provider behavior. From the CLI, usephaseo routing dynamic-routes create, set-keys and deploy, or the
/v1/routing/dynamic-routes API. A route can:
- branch on nested request-body fields, request headers, custom metadata, endpoint, model, or session ID
- split traffic by percentage for A/B tests and gradual rollouts
- enforce daily, weekly, or monthly request and cost limits using the authenticated key’s usage buckets
- call a different model and choose its routing mode, provider preference, and fallback policy
- enable cache-aware and session-aware provider affinity
- attach to one or more inference API keys
Fallback behavior
If a provider returns errors or rate limits, the Gateway can retry or route to another provider that supports the same model. You should still handle 429 and 5xx responses with exponential backoff. Model nodes in a dynamic route can also define an ordered list of fallback models. Phaseo first exhausts the eligible provider attempts for the selected model. If the resulting response is retryable (429, 500, 502, 503, or
504), the Gateway reruns the complete policy and provider-selection pipeline
for each fallback model in order. Client errors are returned immediately and do
not switch models.
Each fallback is independently checked against workspace model restrictions,
guardrails, provider policy, pricing, and capability support. A route can store
up to eight fallback models.
Request-level model fallbacks
model is required and is always the primary model. Add the optional
models array to list fallback models for one request. Phaseo tries model
first, then each models entry in order:
models without model is rejected with 400.
Request-level fallbacks use the same machinery as dynamic-route fallbacks:
- Triggers. The next model is tried only when the previous attempt, after
its own provider retries, ends with
429,500,502,503, or504. Client errors such as400,401,402,403,404,408,413, and422are returned without switching models. A429from a Phaseo budget or free-model quota reached while executing the request also moves to the next model, because a different model may fit within the remaining limit. When no provider serves the primary model at all, for example because it is retired, Phaseo also moves to the next model. Authentication, API key rate limits, and other checks that fail before the primary model runs return immediately. - Limits.
modelsaccepts 1 to 25 entries. Duplicates and entries equal tomodelare ignored. Dynamic routes keep their own limit of eight fallbacks. - Validation. Each entry can be a model ID, a provider-qualified model ID,
or a preset such as
@support. Each attempt is validated as its own request: endpoint and modality support, requested parameters, workspace model restrictions, guardrails, presets, pricing, and BYOK credentials. A fallback that cannot serve the request is skipped and recorded in request logs; it never replaces the failure you would otherwise receive. A fallback that resolves to an attempt already made, with the same model and eligible providers, is skipped. - Logging and billing. Every attempt is a separate request in your logs, with its own usage and billing record, so each attempt is billed exactly as it would be without fallbacks.
- Which model served the request. The response
modelfield shows the model that served the request. Its routing trace lists the primary request ID, the fallback order, and each earlier attempt with its status. - Streaming. Fallbacks happen only before the first byte is sent. An error after a stream has started is returned in that stream.
- Video and music. These requests fall back only while submitting the job. Once a provider accepts a job, a later failure does not start a new job with another model.
models interacts with other routing controls as follows:
- Dynamic routes. Fallbacks configured on an attached dynamic route take
precedence over
models. A fixed model selected by a dynamic route still applies to each attempt. - Presets. A preset can be the primary
modelor amodelsentry. Each attempt applies its own preset constraints, so a preset can narrow the providers a fallback may use. - Auto Routing.
phaseo/autoalready manages ranked fallbacks, so it cannot be combined withmodelsand cannot appear insidemodels.
Multipart endpoints accept repeated
models fields, models[] fields, or one
JSON array string.
Read more in:
Retired models
A retired model is still served while any provider serves it. Once none does, requests fail with410 model_retired, unless the workspace has turned on
retired model routing to send them to a replacement. Your own models list is
always tried before a replacement. See
Model Deprecation and Retirement.
Cache-aware and session-aware affinity
Cache-aware routing is enabled by default on text generation endpoints. Requests that sendprompt_cache_key or session_id, or opt into caching with
cache_control (top-level, provider_options.anthropic.cache_control, or a
cache_control or prompt_cache_breakpoint mark on a message block or tool),
are pinned to the provider and route that served their first successful request.
Other requests are pinned for 15 minutes once a provider reports a prompt-cache
read or write for the same opening context, as long as that provider’s cached
input is cheaper than its standard input.
Pins are kept per workspace and last from 15 minutes to 24 hours, following the
provider’s cache retention. A pin moves only when its provider’s circuit breaker
opens, its recent error rate is high, Phaseo’s managed quota on it runs out, or
the active route, preset, guardrail, or request policy no longer allows it.
When session_id is present, the cache affinity is keyed to the session instead
of only the opening context, and is retained for up to 24 hours of session
activity. See Provider affinity for pin
lifetimes and the affinity hints Phaseo sends to each provider.
Opt out for one request without changing workspace or dynamic-route defaults:
BYOK considerations
Use BYOK when you want Phaseo routing and observability while the selected provider bills model usage to your own account.- The first 250,000 completed BYOK requests in each UTC calendar month have no Phaseo service fee.
- After that allowance, Phaseo charges 2.5% of provider-equivalent cost.
- Keep at least $1 of Phaseo credit available. This protects managed fallback and post-allowance fee collection; provider charges still go directly to your provider account.
- Your provider’s quotas, data policy, model access, and account restrictions still apply.