Skip to content

routing

Auto Self-healing isolation

Circuit Breaker

Self-healing provider isolation

Per-provider circuit breakers open after a configurable number of consecutive failures, removing a failing provider from rotation before it cascades. The breaker stays open for a cool-down, then half-opens and allows one probe request, closing again once it succeeds.

What you get

Everything in the box

  • Per-provider independent breakers
  • Opens on consecutive failures (failure_threshold)
  • Half-open probe after a timeout cool-down
  • Closes after success_threshold successes
  • Open targets excluded from every routing strategy
  • Self-heals with no manual intervention
Full configuration in the docs
config.yaml
targets:
    - virtual_key: openai
      circuit_breaker:
        failure_threshold: 5    # consecutive failures before opening
        success_threshold: 2    # successes in half-open before closing
        timeout: "30s"          # how long the breaker stays open
    - virtual_key: anthropic

When to use it

When to reach for this

Stop a flaky provider degrading latency

When a provider starts timing out, the breaker opens and the gateway routes around it instantly instead of waiting for each request to fail.

Ride out a provider incident

During an outage the breaker keeps the provider isolated and automatically probes for recovery, so traffic returns on its own once the provider is healthy.

Protect a weighted split

In load-balanced routing, a breaker stops a failing target from receiving its weighted share until it recovers, keeping the healthy providers carrying the load.

Alert on tripped providers

Watch gateway_circuit_breaker_state in Prometheus and alert when any provider's breaker opens, turning isolation into an early-warning signal.

FAQ

Frequently asked questions

When does a circuit breaker open?

After failure_threshold consecutive failures for that provider. The breaker then stays open for the configured timeout before testing recovery.

How does a breaker recover?

Once the timeout elapses it enters a half-open state and allows one probe request. After success_threshold successes it closes and full traffic resumes; if the probe fails it re-opens for another cool-down.

Do circuit breakers work with every routing strategy?

Yes. A target whose breaker is open is excluded from selection by all routing strategies — single, fallback, load balance, least-latency, cost-optimized, conditional, content-based, and A/B test.

Are breakers shared across providers?

No. Each target has its own independent breaker, so isolating one failing provider never affects the others.

Can I see when a breaker is open?

Yes. The Prometheus metric gateway_circuit_breaker_state reports each provider's state (0 closed, 1 open, 2 half-open), so you can dashboard and alert on it.

Ready to deploy?

Stand up your AI gateway in minutes — open source, Apache 2.0, no credit card.