Page summary

Configure health checks, backup providers, and automatic failover behavior.

Key takeaways
  • Configure backup providers for interrupted AI coding sessions.
  • Use health checks and failover rules instead of manual recovery.
  • Reduce downtime when an upstream provider is rate limited or unavailable.

4.3 Failover

Overview

The failover feature automatically switches to a backup provider when the primary provider's request fails, ensuring uninterrupted service.

Applicable scenarios:

Prerequisites

Using the failover feature requires:

  1. ✅ The app is in Routing mode (the "Routing" tab on the app page, click "Start routing")
  2. ✅ The failover switch is on in the "Routing" tab
  3. ✅ There are providers in the queue

Failover only supports Claude Code, Codex, Gemini CLI and Grok Build; Aggregation mode doesn't do failover (the queue and settings are kept and take effect again once you return to Routing mode); additive apps (OpenCode, OpenClaw, Hermes, Pi, MiniMax Code) have no failover queue. Official accounts don't join the queue: they use the client's own login and can't rotate with other providers.

Enable Failover

Steps

  1. On the app page, switch to the "Routing" tab and confirm the app is in Routing mode
  2. Turn on the switch with the "Failover" hint at the right of the tab bar (its icon is two crossing arrows)
  3. The first time, a confirmation dialog appears; click "I understand, enable"

The switch only appears when the app is in Routing mode and you're viewing the "Routing" tab.

Switch Description

StateBehavior
OffRoutes only to the selected provider, no automatic switching
OnImmediately switches to queue P1, and automatically switches to the next provider in the queue when a request fails; the status line shows "by queue"

Manage the Failover Queue

Once failover is on, the providers in the "Routing" tab are split into two groups:

Add Backup Providers

Under "Not in queue", click "Add to queue" on the provider card.

Adjust Priority

Use the move up / move down buttons on the card, or drag the card to reorder. Lower numbers mean higher priority, and the queue order follows the order of the provider list on the home page.

Remove Provider

Click "Remove from queue" on the provider card in the queue.

Adjust Retry, Timeout and Circuit Breaker Parameters

Parameters are set per app, with two entry points:

The panel has two parts, "Retry & Timeout Settings" and "Circuit Breaker Settings"; their meanings are covered in the sections below.

Failover Flow

graph TD
    Start[Request arrives at local routing] --> Send[Send to current provider]
    Send --> CheckSuccess{Success?}
    CheckSuccess -- Yes --> Return[Return response]
    CheckSuccess -- No --> LogFail[Record failure]
    LogFail --> CheckCircuit{Check circuit breaker}
    CheckCircuit -- Tripped --> Skip[Skip this provider]
    CheckCircuit -- Not tripped --> IncFail[Increment failure count]
    Skip --> Next{Next in queue?}
    IncFail --> Next
    Next -- Yes --> Switch[Switch provider]
    Switch --> Retry[Retry request]
    Retry --> Send
    Next -- No --> Error[Return error]

Circuit Breaker Configuration

The circuit breaker prevents frequent retries against failing providers.

Configuration Items

Different apps have independent default configurations. Below are general defaults; Claude has its own relaxed configuration.

SettingDescriptionGeneral DefaultClaude DefaultRange
Failure ThresholdConsecutive failures to trigger circuit breaker481-20
Recovery Success ThresholdSuccesses needed in half-open state to close breaker231-10
Recovery Wait TimeTime before attempting recovery after tripping (seconds)60900-300
Error Rate ThresholdError rate that opens the circuit breaker60%70%0-100%
Minimum RequestsMinimum requests before calculating error rate10155-100

💡 Claude has more relaxed default settings due to longer request times, tolerating more failures.

Timeout Configuration

SettingDescriptionGeneral DefaultClaude DefaultRange
Streaming First Byte TimeoutMax wait time for first data chunk (seconds)60901-120
Streaming Idle TimeoutMax interval between data chunks (seconds)12018060-600 (0 to disable)
Non-Streaming TimeoutTotal timeout for non-streaming requests (seconds)60060060-1200

Retry Configuration

SettingDescriptionGeneral DefaultClaude DefaultRange
Max RetriesNumber of retries on request failure360-10

💡 Gemini's default max retries is 5.

Circuit Breaker States

StateDescription
ClosedNormal state, requests allowed
OpenCircuit broken, this provider is skipped
Half-OpenAttempting recovery, sending probe requests

State Transitions

stateDiagram-v2
    [*] --> Closed: Initialize
    Closed --> Open: Failures >= threshold
    Open --> HalfOpen: Recovery wait time expires
    HalfOpen --> Closed: Probe successes >= recovery threshold
    HalfOpen --> Open: Probe failed

Health Status Indicators

Provider Cards

In routing mode, provider cards display health status badges:

BadgeStatusDescription
🟢Operational0 consecutive failures
🟡DegradedHas failures but circuit not tripped
🔴Circuit OpenCircuit breaker tripped, temporarily skipped

Queue

Provider cards in the failover queue also display health status; the "Routing" marker shows the provider actually in use (it changes after a successful failover and isn't necessarily the head of the queue).

Failover Logs

Each failover event records:

InformationDescription
TimeWhen it occurred
Original ProviderThe provider that failed
New ProviderThe provider switched to
Failure ReasonError message

Viewable in the request logs within usage statistics.

Best Practices

Queue Configuration Recommendations

  1. Primary provider: The most stable and fastest provider
  2. First backup: Second-best choice
  3. Second backup: Last resort

Circuit Breaker Configuration Recommendations

ScenarioFailure ThresholdRecovery Wait
High availability requirement230 seconds
General scenario360 seconds
Tolerant of occasional failures5120 seconds

Monitoring Recommendations

Periodically check:

FAQ

Failover Not Triggering

Check:

  1. Is local routing running (Settings → Local routing)
  2. Is the app in Routing mode (Aggregation mode doesn't do failover)
  3. Is the failover switch in the "Routing" tab on
  4. Are there backup providers in the queue

Failover Triggering Too Frequently

Possible causes:

Solutions:

All Providers Circuit-Broken

Wait for the recovery wait time to expire for automatic recovery, or:

  1. In "Settings → Local routing", switch the app back to direct, stop the service, then start routing again
  2. Or adjust the circuit breaker parameters