> ## 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 Manager • Rust AI Agent SDK

> FailoverManager: Manages failover between multiple LLM auth profiles. Provides automatic failover when rate limits or errors occur, with configurable retry behavior...

# FailoverManager

> Defined in the [**failover**](../modules/failover) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Manages failover between multiple LLM auth profiles. Provides automatic failover when rate limits or errors occur, with configurable retry behavior and cooldown periods.

## Fields

| Name            | Type                          | Description            |
| --------------- | ----------------------------- | ---------------------- |
| `config`        | `FailoverConfig`              | Failover configuration |
| `profiles`      | `Vec&lt;AuthProfile&gt;`      | Registered profiles    |
| `current_index` | `usize`                       | Current profile index  |
| `callbacks`     | `Vec&lt;FailoverCallback&gt;` | Failover callbacks     |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new(config: FailoverConfig) -> Self
```

Create a new failover manager.

**Parameters:**

| Name     | Type             |
| -------- | ---------------- |
| `config` | `FailoverConfig` |

### `default_config`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn default_config() -> Self
```

Create with default config.

### `add_profile`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn add_profile(&mut self, profile: AuthProfile) -> ()
```

Add an auth profile.

**Parameters:**

| Name      | Type          |
| --------- | ------------- |
| `profile` | `AuthProfile` |

### `remove_profile`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn remove_profile(&mut self, name: &str) -> bool
```

Remove a profile by name.

**Parameters:**

| Name   | Type   |
| ------ | ------ |
| `name` | `&str` |

### `get_profile`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn get_profile(&self, name: &str) -> Option<&AuthProfile>
```

Get a profile by name.

**Parameters:**

| Name   | Type   |
| ------ | ------ |
| `name` | `&str` |

### `get_profile_mut`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn get_profile_mut(&mut self, name: &str) -> Option<&mut AuthProfile>
```

Get a mutable profile by name.

**Parameters:**

| Name   | Type   |
| ------ | ------ |
| `name` | `&str` |

### `list_profiles`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn list_profiles(&self) -> &[AuthProfile]
```

List all profiles.

### `get_next_profile`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn get_next_profile(&mut self) -> Option<&AuthProfile>
```

Get the next available profile. Returns profiles in priority order, skipping those that are rate limited or in cooldown.

### `mark_failure`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn mark_failure(&mut self, profile_name: &str, error: &str, is_rate_limit: bool) -> ()
```

Mark a profile as failed.

**Parameters:**

| Name            | Type   |
| --------------- | ------ |
| `profile_name`  | `&str` |
| `error`         | `&str` |
| `is_rate_limit` | `bool` |

### `mark_success`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn mark_success(&mut self, profile_name: &str) -> ()
```

Mark a profile as successful.

**Parameters:**

| Name           | Type   |
| -------------- | ------ |
| `profile_name` | `&str` |

### `on_failover`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn on_failover(&mut self, callback: FailoverCallback) -> ()
```

Register a callback for failover events.

**Parameters:**

| Name       | Type               |
| ---------- | ------------------ |
| `callback` | `FailoverCallback` |

### `get_retry_delay`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn get_retry_delay(&self, attempt: u32) -> Duration
```

Calculate retry delay for an attempt.

**Parameters:**

| Name      | Type  |
| --------- | ----- |
| `attempt` | `u32` |

### `status`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn status(&self) -> FailoverStatus
```

Get failover manager status.

### `reset_all`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn reset_all(&mut self) -> ()
```

Reset all profiles to available status.

### `len`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn len(&self) -> usize
```

Get the number of profiles.

### `is_empty`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn is_empty(&self) -> bool
```

Check if empty.

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/failover/mod.rs#L292">
  `praisonai/src/failover/mod.rs` at line 292
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Failover" icon="shield" href="/docs/rust/failover" />

  <Card title="Rust Retry" icon="rotate-right" href="/docs/rust/retry" />
</CardGroup>
