> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Failover

> Automatic backup when things fail

Agents can failover to backup models when the primary fails.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Automatic Failover"
        A[📤 Request] --> B[🤖 Primary]
        B -->|Fails| C[🤖 Backup]
        C --> D[✅ Success]
    end

    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff
    class B agent
    class A,C,D tool
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

```

## Quick Start

**1. Simple Usage**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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. With Configuration**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const agent = new Agent({
  llm: 'gpt-4o',
  fallback: [
    'anthropic/claude-3',
    'google/gemini-pro'
  ]
});
```

***

## User Interaction Flow

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant LLM1 as GPT-4o
    participant LLM2 as Backup
    
    User->>Agent: Request
    Agent->>LLM1: Try primary
    LLM1--xAgent: Fail
    Agent->>LLM2: Try backup
    LLM2-->>Agent: Success
    Agent-->>User: Response
```

***

## Configuration Levels

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
// 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

> [card] [FailoverConfig](https://praison.ai/docs/sdk/reference/typescript/classes/FailoverConfig.md)
>
> Complete configuration options

> [card] [FailoverManager](https://praison.ai/docs/sdk/reference/typescript/classes/FailoverManager.md)
>
> Manager class documentation

***

## Best Practices

> [accordion] Include cheaper fallbacks
>
> Use lower-cost models as last resort.

> [accordion] Mix providers
>
> Different providers have different outages.

> [accordion] Test fallback paths
>
> Verify backups work before production.

***

## Related

> [card] [Execution](https://praison.ai/docs/js/execution.md)
>
> Execution settings

> [card] [Providers](https://praison.ai/docs/js/providers.md)
>
> LLM providers


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.