Try Bifrost Enterprise free for 14 days.
Request access
[ ADAPTIVE ROUTING ]

Adaptive Routing
AI Load Balancing and Automatic Failover for LLMs

When a provider goes down or an API key hits a rate limit, Bifrost Enterprise moves LLM traffic to the healthiest provider and key on its own, and moves it back as they recover.

Bifrost Enterprise | Live Traffic Only | No Health Checks

[ DEFINITION ]

What Adaptive Routing Does

Adaptive Routing is a Bifrost Enterprise feature that routes every request to the healthiest provider and key, holds back keys a provider refuses, and shows what it did and why. It judges health from your live traffic: errors count the most, then latency, then load, recalculated every few seconds. A provider or key that starts failing loses traffic within seconds and earns it back as it recovers.

01

Provider selection

For a request that does not name a provider, the healthiest provider for the model is picked and the other healthy ones become its fallbacks.

02

Key selection

Within the chosen provider, the key is picked by live health, latency and load instead of only the weights you set.

03

Held keys

A key the provider refuses is taken out of rotation on every node and checked again by a single live request after a wait.

04

Redirecting named providers

Optional. A request that names a provider that is failing for its model can be sent to a healthy provider, or to its own fallbacks.

05

Routing history and incidents

Every node records key and provider health and every decision it changes, so the dashboard can show what happened, when, and what adaptive routing did about it.

No requests of its own

Adaptive routing never sends health checks, pings or test calls to a provider. Even a held key is checked by letting one of your real requests through to it.

Provider Selection

For a request that does not name a provider, adaptive routing picks the healthiest provider that serves the model.

  • The other healthy providers become its fallbacks, best first
  • A provider that has failed for the model is left out until a key recovers
  • Providers that governance does not allow for the request are never considered
  • Each node keeps the health of every provider from the requests it sends, and recalculates it every few seconds

Key Selection

On the provider the request goes to, adaptive routing picks the key by live health, latency and load instead of only the weights you set.

  • Healthier, faster and less loaded keys get more of the traffic
  • Every usable key keeps a share, so a key that has recovered is noticed
  • Errors count the most, then latency, then load
  • While Adaptive Key Selection is on, the weights set on keys are not used

Held Keys

Some provider answers repeat on every request until something changes, so waiting for an error rate to climb only costs requests.

  • A held key is out of rotation on every node, in every region
  • After a wait, one live request per node is let through to check it
  • The wait starts at 30 seconds and doubles after each failed check, or follows the wait the provider states
  • A key that serves its check goes to Recovering and earns its traffic back

Redirecting Named Providers

Optional. A request that names a provider that is failing for its model can be sent to a healthy provider, or to its own fallbacks.

  • Redirect To: Best healthy provider moves the request to another healthy provider for the same model
  • Redirect To: The request’s own fallbacks moves it to its first fallback that is not failing
  • The failing provider stays as the last fallback
  • If nothing healthier is available, the request stays on the named provider rather than failing

Routing History and Incidents

Every node records key and provider health and every decision it changes, so the dashboard can show what happened, when, and what adaptive routing did about it.

  • The dashboard shows Incidents detected, Requests saved, Requests failed and Chosen by adaptive routing
  • Health over time has one row per provider and model, with its keys underneath
  • Each incident has a status, from Needs attention to Resolved, and says what to do
  • Every request log starts its Routing tab with an Adaptive Routing card

[ STATES ]

Provider and Key States

A key has a state for each model it serves. A provider has a state for each model, rolled up from the keys that can serve that model.

Key states in adaptive routing and the traffic each gets
Key stateWhat it meansTraffic
HealthyServing normally.Its full share.
DegradedA small share of its requests fail, or it is much slower than usual.Less than its share.
FailedFailing steadily, or held because the provider refused it.None, apart from the single request that checks a held key.
RecoveringBack after a failure or a hold.A reduced share that grows as it serves cleanly, until it is Healthy again.

A provider is Healthy when every key is serving, Degraded when some keys failed and the rest still serve, and Failed when every key that can serve the model failed.

[ HELD KEYS ]

What Holds a Key

Six provider answers hold a key. A hold on one model leaves the key serving its other models. Network errors, timeouts and plain 5xx responses never hold a key.

Reasons adaptive routing holds an API key
Reason (dashboard)failure_classWhat is heldLongest wait without a provider hint
Key rejectedcredentialThe whole key, for every model15 minutes
Out of quotaquotaThe whole key, for every model5 minutes
No model accessmodel_accessThe model5 minutes
Model retiredmodel_goneThe model30 minutes
Region blockedregion_blockedThe model15 minutes
Rate limitedrate_limitThe model2 minutes

[ SETTINGS ]

Adaptive Routing Settings

The scoring, thresholds and wait times are tuned in Bifrost and are not configurable. The settings decide what adaptive routing is allowed to change, and how it records history.

Adaptive routing settings, their keys and defaults
Setting (UI)KeyDefault
Adaptive Provider Selectiondirection_selection_enabledOn
Adaptive Key Selectionroute_selection_enabledOn
Add Fallbacks When a Provider Is Namedappend_fallbacks_to_pinnedOff
Redirect Away from Failing Providersreroute_failed_directionsOff
Redirect Toreroute_targetpool
Skip Failing Fallbacksprune_failed_fallbacksOff
Record Routing Historyhistory_enabledOn
History Retention (days)history_retention_days7 (1 to 30)
Save Routing State Every (seconds)snapshot_persist_interval_seconds300 (5 to 86400)

Common setups

Callers send bare model names
The defaults. Turn on Skip Failing Fallbacks if callers send their own fallbacks.
Callers, routing rules or virtual keys name providers
Add Fallbacks When a Provider Is Named on, Redirect Away from Failing Providers on, and Redirect To set to Best healthy provider.
Strictly pinned traffic (compliance, data residency, direct keys)
Add Fallbacks When a Provider Is Named and Redirect Away from Failing Providers off. Restrict providers with governance.

Change settings

Open Adaptive Routing, then Settings, in the sidebar, use the /api/adaptive-routing/config API, or add a top-level load_balancer_config block to config.json. Only the keys you list are applied; the rest keep their defaults.

config.json
{
  "load_balancer_config": {
    "reroute_failed_directions": true,
    "reroute_target": "fallbacks",
    "history_retention_days": 14
  }
}

[ WHERE IT FITS ]

With Other Routing Features

Adaptive routing runs after routing rules and virtual keys, and before session affinity. To choose a model by how hard a request is, pair it with an LLM router.

  1. 01

    Routing rules

    Run before adaptive routing. A rule that sets a provider makes the request named, and its fallbacks become the request’s own.

  2. 02

    Virtual keys

    Limit every provider adaptive routing picks or adds. Their weighted provider configs pick before adaptive routing, so that traffic is named.

  3. 03

    Adaptive routing

    Picks the provider for requests that name none, and the key on the provider the request goes to.

  4. 04

    Session affinity

    Runs after adaptive routing and can keep a session on its provider and key, but not on one that is failing or held on this node.

  5. 05

    Retries and fallbacks

    Run per attempt on the chain adaptive routing leaves, and decide which failures retry a key, rotate to another, or move to the next fallback.

[ COMMON CASES ]

Common Cases

How each case shows up on the dashboard timeline and its incident, what it means, and what to do.

  • Healthy
  • Failed
  • Recovering
  • Held
  • Held for a rate limit

Key rejected

The provider returned an authentication error for the key, for example because it was revoked or rotated outside Bifrost. The provider’s other keys carry its traffic.

What to doReplace the key in the provider’s settings. Editing the key releases the hold, and adaptive routing checks the new key with live traffic.

Key rate limited

The provider rate limited the key for one model. Adaptive routing held it for as long as the provider asked, sent its traffic to the other keys, and the first check after the wait served.

What to doNothing, unless it keeps happening. Frequent rate limits on one key mean it needs more capacity or another key alongside it.

Provider outage

The provider was down or erroring for the model. Requests that did not name a provider were sent to the other providers for the model.

What to doNothing for requests adaptive routing could move. If requests failed with nothing healthier to send them to, add another provider for the model or a fallback.

Requests kept on a failing provider

These requests named the provider and Redirect Away from Failing Providers is off, so adaptive routing left them on it.

What to doTurn on Redirect Away from Failing Providers, and Add Fallbacks When a Provider Is Named if those requests should fall back while the provider recovers.

[ LIMITS ]

Limits

Four things to know before you rely on it. Budgets and rate limits per team or customer belong to AI governance, and running several nodes is covered in enterprise scalability.

  1. 01

    Health is per node

    Each node scores providers and keys from its own traffic, so two nodes can briefly disagree, and nodes in different regions see their own latency. Held keys are shared across the cluster.

  2. 02

    Changes follow traffic

    Health is recalculated every few seconds, so a provider that starts failing loses traffic within seconds, not on the first error. Retries and fallbacks protect each request in the meantime.

  3. 03

    New keys start at full share

    A key or provider adaptive routing has not measured yet competes at a fair share and settles within a cycle or two.

  4. 04

    Ranking is relative

    Providers and keys are ranked against each other, not against a fixed latency or cost target. Cost and budget decisions belong to governance.

See Adaptive Routing on Your Own Traffic

Adaptive Routing is part of Bifrost Enterprise, which you can try free for 14 days. For the engineering detail, read a closer look at Bifrost adaptive routing.

[ BIFROST FEATURES ]

Open Source & Enterprise

Everything you need to run AI in production, from free open source to enterprise-grade features.

01 Governance

SAML support for SSO and Role-based access control and policy enforcement for team collaboration.

02 Adaptive Load Balancing

Automatically optimizes traffic distribution across provider keys and models based on real-time performance metrics.

03 Cluster Mode

High availability deployment with automatic failover and load balancing. Peer-to-peer clustering where every instance is equal.

04 Alerts

Real-time notifications for budget limits, failures, and performance issues on Email, Slack, PagerDuty, Teams, Webhook and more.

05 Log Exports

Export and analyze request logs, traces, and telemetry data from Bifrost with enterprise-grade data export capabilities for compliance, monitoring, and analytics.

06 Audit Logs

Comprehensive logging and audit trails for compliance and debugging.

07 Vault Support

Secure API key management with HashiCorp Vault, AWS Secrets Manager, Google Secret Manager, and Azure Key Vault integration.

08 VPC Deployment

Deploy Bifrost within your private cloud infrastructure with VPC isolation, custom networking, and enhanced security controls.

09 Guardrails

Automatically detect and block unsafe model outputs with real-time policy enforcement and content moderation across all agents.

[ SHIP RELIABLE AI ]

Try Bifrost Enterprise with a 14-day Free Trial

[quick setup]

Drop-in replacement for any AI SDK

Change just one line of code. Works with OpenAI, Anthropic, Vercel AI SDK, LangChain, and more.

1import os
2from anthropic import Anthropic
3
4anthropic = Anthropic(
5 api_key=os.environ.get("ANTHROPIC_API_KEY"),
6 base_url="https://<bifrost_url>/anthropic",
7)
8
9message = anthropic.messages.create(
10 model="claude-3-5-sonnet-20241022",
11 max_tokens=1024,
12 messages=[
13 {"role": "user", "content": "Hello, Claude"}
14 ]
15)
Drop in once, run everywhere.

[ FAQ ]

Adaptive Routing FAQs

Common questions about adaptive routing, held keys and failing providers.

Adaptive Routing is a Bifrost Enterprise feature that picks where each LLM request goes from what it observes on live traffic. It makes two choices for every request: the provider that serves the model, and the API key within that provider. A provider or key that starts failing loses its traffic and gets it back as it recovers, without anyone editing weights or fallbacks.

Adaptive load balancing is the general technique: share traffic by live measurements instead of fixed weights. Adaptive Routing is how Bifrost Enterprise applies it to LLM traffic, at two levels, provider and key, and it adds held keys, optional redirects for requests that name a provider, and a recorded history of incidents. For the general concept, read what adaptive load balancing is.

Weighted load balancing splits traffic by the weights you set and keeps doing so when a key starts failing. With Adaptive Key Selection on, the weights set on keys are not used: the key is picked from live health, latency and load, with errors counting the most. Turn Adaptive Key Selection off when your key weights must decide the split, for example to divide traffic by contract. Held keys are still skipped either way.

No. Adaptive routing never sends requests of its own to a provider: no health checks, pings or test calls. Everything it knows comes from your live traffic and from how its routing decisions turned out. Even a held key is checked by letting one of your real requests through to it.

When every key that can serve a model on a provider has failed, the provider is Failed for that model and is left out. Requests that do not name a provider go to the healthiest remaining provider, with the other healthy ones as fallbacks. Requests that name the failing provider are moved only when Redirect Away from Failing Providers is on. See also automatic failover and load balancing for LLM apps.

Adaptive routing holds the key. A held key is out of rotation on every node, and after a wait one live request is let through to check it. A rate limit holds the key for one model for as long as the provider asks, or up to 2 minutes when it does not say. A rejected key is held for every model, with waits that climb to 15 minutes, until it is replaced, edited or released.

Health is recalculated every few seconds, so a provider that starts failing loses traffic within seconds, not on the first error. Retries and fallbacks protect each request in the meantime. A sharp burst of errors moves a key straight to Failed without passing through Degraded.

No. Adaptive Routing is part of Bifrost Enterprise. Open-source Bifrost includes retries, fallbacks and weighted load balancing across keys and providers, which you configure yourself.

Yes. By default adaptive routing keeps a request that names a provider on that provider with its own fallbacks, and only picks the key. For strictly pinned traffic such as compliance or data residency, leave Add Fallbacks When a Provider Is Named and Redirect Away from Failing Providers off, and restrict providers with governance.