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

# Circuit Breaker

> Automatically stop routing to unhealthy targets until they recover.

> [!NOTE]
>
> Available on all Portkey [plans](https://portkey.ai/pricing).

Circuit breakers prevent cascading failures by temporarily blocking requests to targets that are failing.

## Config Schema

| Field | Description |
| - | - |
| `failure_threshold` | Number of failures to open circuit |
| `failure_threshold_percentage` | Percentage failure rate to trip circuit *(optional)* |
| `cooldown_interval` | Milliseconds to wait before retrying (min: 30s) |
| `failure_status_codes` | HTTP codes considered failures *(optional, default: >500)* |
| `minimum_requests` | Requests required before evaluating failure rate *(optional)* |

> [!NOTE]
>
> * Strategies inherit `cb_config` from parent if not set
> * Targets inherit from their parent strategy

> [!WARNING]
>
> `conditional` mode strategies are **not** evaluated by circuit breaker.

## Example

```json theme={"system"}
{
  "strategy": {
    "mode": "fallback",
    "cb_config": {
      "failure_threshold_percentage": 20,
      "minimum_requests": 10,
      "cooldown_interval": 60000,
      "failure_status_codes": [401, 429, 500]
    }
  },
  "targets": [
    { "override_params": { "model": "@openai-prod/gpt-4o" } },
    { "override_params": { "model": "@anthropic-prod/claude-3-5-sonnet-20241022" } }
  ]
}
```

> [!NOTE]
>
> The `@provider-slug/model-name` format automatically routes to the correct provider. Set up providers in [Model Catalog](https://app.portkey.ai/model-catalog).

## How It Works

Circuit breaker tracks per strategy path:

* Failure and success counts
* Time of first failure
* Failure rate (when `minimum_requests` threshold met)

**Circuit opens (OPEN)** when:

* Failure count exceeds `failure_threshold`, or
* Failure rate exceeds `failure_threshold_percentage`

**Circuit closes (CLOSED)** automatically after `cooldown_interval` passes.

## Runtime Behavior

```mermaid theme={"system"}
flowchart TD
    A[Request arrives] --> B[Evaluate strategy targets]
    B --> C{All targets OPEN?}
    C -->|Yes| D[Bypass circuit breaker]
    D --> E[Use all targets]
    C -->|No| F[Use healthy targets only]
    E --> G[Route request]
    F --> G
```

* Unhealthy targets removed from routing
* If all targets are OPEN, circuit breaker is bypassed

***

> [card] [Portkey is now PRISMA AIRS AI Gateway. See it in action.](https://www.paloaltonetworks.in/ai-security/ai-gateway?utm_source=portkey\&utm_medium=referral\&utm_campaign=prisma_airs\&utm_content=docs_nav#contact)
>
> Contact Us


## Related topics

- [Circuit Breakers](https://docs.portkey.ai/docs/product/mcp-gateway/circuit-breakers.md)
- [June](https://docs.portkey.ai/docs/changelog/2025/june.md)
- [May](https://docs.portkey.ai/docs/changelog/2026/may.md)
- [Gateway Config Object](https://docs.portkey.ai/docs/api-reference/inference-api/config-object.md)
- [Anthropic](https://docs.portkey.ai/docs/integrations/llms/anthropic.md)


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