Skip to main content
Agents can failover to backup models when the primary fails.

Quick Start

1

Set Fallback Models

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
2

Multi-Provider Failover

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

OptionDescription
fallbackBackup models list
retriesAttempts per model
strategyHow to select backup
healthCheckSkip known-down models

API Reference

FailoverConfig

Complete configuration options

FailoverManager

Manager class documentation

Best Practices

Use lower-cost models as last resort.
Different providers have different outages.
Verify backups work before production.