Overview
Circuit Breaker in Bifrost Enterprise automatically reroutes LLM requests to a fallback provider when a primary provider endpoint shows signs of degradation. Instead of letting throttled or degraded requests fail, Bifrost detects the signal in the response headers, opens the circuit, and transparently redirects subsequent requests to your configured fallback — until the cooldown window expires and the primary is retried.Key Features
How It Works
Every request that matches a circuit breaker policy passes through two hooks:- Pre-request hook — checks whether the circuit is open. If open, the request is immediately rerouted to the fallback provider and model. The original target is not contacted. If the fallback target’s own circuit is open too, the request follows that target’s policy in turn, until it reaches a target whose circuit is closed; a chain that leads back to a target it already passed stops at the last new one. Entries in the request’s fallback chain whose circuit is open are redirected the same way.
- Post-response hook — evaluates the response headers from the primary target against the policy’s condition. If the condition matches, the circuit opens for the configured cooldown duration.
Circuit breaker policies act on response headers you choose, per provider and model. Separately, Adaptive Load Balancing holds a key on its own when the provider refuses it (a rejected credential, an exhausted quota, no model access, a retired model, a blocked region, or a rate limit). The two work side by side and need no configuration between them.
Configuration
Web UI
Navigate to Circuit Breaker in the Bifrost dashboard to create and manage policies.
config.json
Add acircuit_breaker_config block at the root of your config.json:
Policy Properties
Condition Properties
Signal Properties
Signals
Signals define what Bifrost watches for in the provider’s HTTP response. Each signal inspects a single response header using one of three match modes:Key-Level Sub-Circuits
By default, a policy uses a single shared circuit for all API keys serving the configured primary provider and model. If one key is degraded, the circuit opens and all requests to that provider+model route to the fallback — even requests that could have been served by a healthy key. Setprimary_key_ids to a list of key UUIDs to enable per-key tracking:
Cooldown
When the circuit opens, Bifrost blocks the primary provider for a cooldown duration before probing it again.Static cooldown
Setdefault_cooldown to a Go duration string. The circuit stays open for exactly this duration:
ns, us, ms, s, m, h.
Header-driven cooldown
Some providers return a header telling clients how long to back off. Setcooldown_header to read that value (expected in milliseconds):
retry-after-ms is present and parsable, Bifrost uses its value as the cooldown. If the header is absent or cannot be parsed, default_cooldown is used as the fallback.
Example: Azure PTU → PAYG Spillover
Azure OpenAI Provisioned Throughput Units (PTU) offer predictable latency at fixed capacity. When PTU capacity is exhausted, Azure signals spillover via a response header. This policy detects that signal and routes subsequent requests to a Pay-As-You-Go deployment until the PTU recovers.- Requests arrive targeting
gpt-4o-ptuon Azure. - When PTU capacity is exhausted, Azure returns
X-Ms-Is-Spilled-Over: truein the response. - Bifrost detects the header, opens the circuit for 30 seconds.
- All subsequent requests within the cooldown window are transparently rerouted to
gpt-4o-paygo— no changes required in your application. - After 30 seconds, Bifrost probes the PTU deployment again. If spillover is no longer signalled, the circuit closes and PTU traffic resumes.

