Quick Start
How It Works
| Component | Role |
|---|---|
| AuthProfile | Credentials for a single provider |
| FailoverManager | Orchestrates failover logic |
| FailoverConfig | Retry and backoff settings |
| ProviderStatus | Tracks provider health |
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
max_retries | int | 3 | Maximum retry attempts |
retry_delay | float | 1.0 | Initial retry delay |
exponential_backoff | bool | True | Use exponential backoff |
max_retry_delay | float | 60.0 | Maximum retry delay |
failover_on_rate_limit | bool | True | Failover on 429 |
failover_on_timeout | bool | True | Failover on timeout |
Auth Profiles
Configure credentials for each provider:| Field | Type | Description |
|---|---|---|
name | str | Unique profile identifier |
provider | str | Provider: openai, anthropic, etc. |
api_key | str | API key (masked in logs) |
base_url | str | Custom API endpoint |
priority | int | Failover priority (1 = highest) |
weight | float | Load balancing weight |
rate_limit | int | Rate limit (requests/min) |
Common Patterns
- Multi-Provider
- Cost Optimization
- Regional Failover
Failover Callbacks
React to failover events:Provider Status
Monitor provider health:Best Practices
Configure multiple providers
Configure multiple providers
Always have at least 2-3 providers configured. This ensures availability even during major outages.
Use exponential backoff
Use exponential backoff
Enable
exponential_backoff=True to avoid hammering providers during issues. This helps you stay within rate limits.Set appropriate priorities
Set appropriate priorities
Order providers by cost and reliability. Put cheaper/faster providers first, with premium providers as fallback.
Monitor failover events
Monitor failover events
Use the
on_failover callback to track when failovers occur. This helps identify provider issues early.
