Failover
Automatic backup when things fail
Agents can failover to backup models when the primary fails.
Quick Start
- Simple Usage
typescript import { Agent } from 'praisonai'; const agent = new Agent({ llm: 'gpt-4o', fallback: ['gpt-4-turbo', 'gpt-3.5-turbo'] }); await agent.chat('Hello'); // Uses gpt-4o, falls back if unavailable - With Configuration
typescript const agent = new Agent({ llm: 'gpt-4o', fallback: [ 'anthropic/claude-3', 'google/gemini-pro' ] });
User Interaction Flow
Configuration Levels
// Level 1: Array - Simple fallback list
const agent = new Agent({
llm: 'gpt-4o',
fallback: ['gpt-4-turbo', 'gpt-3.5-turbo']
});
// Level 2: Dict - With options
const agent = new Agent({
llm: 'gpt-4o',
fallback: {
models: ['gpt-4-turbo', 'gpt-3.5-turbo'],
retries: 2
}
});
// Level 3: Instance - Full control
const agent = new Agent({
failover: {
primary: 'gpt-4o',
fallbacks: ['gpt-4-turbo', 'claude-3'],
strategy: 'round-robin', // or 'priority'
healthCheck: true
}
});Failover Options
| Option | Description |
|---|---|
fallback | Backup models list |
retries | Attempts per model |
strategy | How to select backup |
healthCheck | Skip known-down models |
API Reference
FailoverConfigComplete configuration options
FailoverManagerManager class documentation
Best Practices
Include cheaper fallbacks
Use lower-cost models as last resort.
Mix providers
Different providers have different outages.
Test fallback paths
Verify backups work before production.