Docs/Concepts/Failover

Provider Failover

Automatic fallback to backup providers when your primary provider is unavailable, ensuring maximum uptime for your AI applications.

Overview

Cencori automatically handles provider failures by retrying requests and falling back to alternative providers. This ensures your users never see an error when a single provider has issues.

Automatic Retries

Retries with exponential backoff before failover

Circuit Breaker

Skips failing providers to reduce latency

Model Mapping

Maps to equivalent models on fallback providers

How It Works

  1. 1
    Request arrives — Cencori routes to your requested model (e.g., gpt-5)
  2. 2
    Primary fails — Retries up to 3x with exponential backoff (100ms, 200ms, 400ms)
  3. 3
    Fallback activated — Routes to your configured fallback provider with equivalent model
  4. 4
    Response returned — Includes fallback_used: true so you know

Configuration

Configure failover in your Project Settings → Infrastructure tab:

Failover Settings

Enable automatic fallback

Route to backup providers on failure

Enabled

Fallback provider

Preferred backup when primary fails

Anthropic

Max retries before fallback

Number of retry attempts

3

Model Mapping

When falling back to another provider, Cencori maps your model to an equivalent:

Original Model→ Anthropic→ Google
gpt-5claude-opus-4gemini-3-pro
gpt-4oclaude-sonnet-4gemini-2.5-flash
claude-opus-4gemini-3-pro
gemini-3-proclaude-opus-4

Response Format

When a fallback is used, the response includes additional fields:

Note on Streaming

For streaming responses, fallback_used is included in the first SSE chunk only.

Circuit Breaker

Cencori uses a circuit breaker pattern to prevent cascading failures:

Closed (Normal)

All requests go to the provider

Open (After 5 failures)

Provider skipped, requests go directly to fallback

Half-Open (After 60s)

One test request sent; if successful, circuit closes

Webhooks

Get notified when failover occurs by subscribing to the model.fallback webhook event in your project settings.