---
slug: "pi-exa-rotate"
source_type: "readme"
source_url: "https://cdn.jsdelivr.net/gh/themuuln/pi-exa-rotate@main/README.md"
repo: "https://github.com/themuuln/pi-exa-rotate"
source_file: "README.md"
branch: "main"
---
# pi-exa-rotate

Exa API key rotation and usage tracking for [Pi coding agent](https://pi.dev).

Automatically rotates between multiple Exa API keys when quotas are exhausted. Tracks usage per key and provides commands to manage keys.

## Features

- **Automatic rotation** — switches keys when one exhausts (1,000/month limit)
- **Usage tracking** — monitors requests per key, resets monthly
- **Status display** — shows usage in footer status bar
- **Key management** — commands to list, add, remove keys
- **Fallback support** — works alongside Gemini Web fallback

## Install

```bash
pi install npm:pi-exa-rotate
```

## Setup

### 1. Create keys file

Create `~/.pi/exa-keys.json`:

```json
{
  "keys": [
    "exa-YOUR_FIRST_KEY",
    "exa-YOUR_SECOND_KEY",
    "exa-YOUR_THIRD_KEY"
  ],
  "currentIndex": 0
}
```

### 2. Get Exa API keys

1. Go to [exa.ai](https://exa.ai)
2. Create account (get $10 free credits + 1,000 requests/month)
3. Get API key at [exa.ai/settings/api-keys](https://exa.ai/settings/api-keys)
4. Repeat for additional accounts

### 3. Reload Pi

```
/reload
```

## Commands

| Command | Description |
|---------|-------------|
| `/exa-keys list` | List all configured keys |
| `/exa-keys add <key>` | Add a new key |
| `/exa-keys remove <index>` | Remove a key by index |
| `/exa-keys current` | Show active key and usage |
| `/exa-status` | Show detailed usage status |

## How It Works

1. Tracks usage in `~/.pi/exa-usage.json`
2. When count reaches 1,000 (monthly limit), rotates to next key
3. Resets counter for new key
4. Shows status in footer: `Exa: 45/1000 (955 left)`

## Quota Math

| Accounts | Free Tier | Credits | Total/Month |
|----------|-----------|---------|-------------|
| 1 | 1,000 | $10 (~1,400) | ~2,400 |
| 2 | 2,000 | $20 (~2,800) | ~4,800 |
| 3 | 3,000 | $30 (~4,200) | ~7,200 |

## Config

Your `~/.pi/web-search.json` should have:

```json
{
  "provider": "exa",
  "exaApiKey": "exa-CURRENT_KEY"
}
```

The extension automatically updates `exaApiKey` when rotating.

## License

MIT
