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

# Pi

> Requesty routing for the Pi Coding Agent

[Pi](https://pi.dev) is an AI coding agent that runs locally on your machine.

Using the Requesty integration, you can:

* Access **600+ models** from OpenAI, Anthropic, Google, Mistral, and many other providers through one API key.
* Get **automatic prompt caching** on Anthropic models, reducing cost significantly on multi-turn conversations.
* Track and manage your spend in a single location.
* Apply [fallback policies](https://docs.requesty.ai/features/fallback-policies.md), [load balancing](https://docs.requesty.ai/features/load-balancing-policies.md), and [latency routing](https://docs.requesty.ai/features/latency-routing.md) to keep your agent responsive.

> [!TIP]
>
> The [Requesty CLI](https://docs.requesty.ai/integrations/requesty-cli.md) writes this configuration for you: run `requesty`, select **Pi**, pick a model, and it backs up your existing config before writing.

## Prerequisites

* Pi installed on your machine. See [pi.dev](https://pi.dev) for installation instructions.
* A Requesty API key from the [API Keys page](https://app.requesty.ai/api-keys).

## Configuration

**1. Install Pi**

Follow the instructions at [pi.dev](https://pi.dev) to download and install Pi on your machine.

**2. Install the Requesty extension**

```txt theme={"dark"}
pi install git:github.com/requestyai/pi-requesty
```

To update it later, run `pi update --extensions` and restart Pi.

**3. Add your API key**

Store the key in Pi's credentials file, `~/.pi/agent/auth.json`. The `key` value can point at an environment variable, run a command that prints the key, or be the key itself:

```json Environment variable theme={"dark"}
{
  "requesty": { "type": "api_key", "key": "$REQUESTY_API_KEY" }
}
```

```json Password manager theme={"dark"}
{
  "requesty": { "type": "api_key", "key": "!security find-generic-password -s requesty -w" }
}
```

```json Plain key theme={"dark"}
{
  "requesty": { "type": "api_key", "key": "rqsty-sk-...." }
}
```

Get a key from the [API Keys page](https://app.requesty.ai/api-keys). With the environment variable option, export `REQUESTY_API_KEY` in the shell that starts Pi. A `!command` runs in your shell and can be any password manager CLI; it runs twice when Pi starts, so some password managers ask twice.

> [!NOTE]
>
> Keys in `~/.pi/agent/models.json` (`providers.requesty.apiKey`) still work. When both files hold a key, `auth.json` wins. If you set `PI_CODING_AGENT_DIR`, both files are read from that folder instead of `~/.pi/agent`.

**4. Start Pi**

```txt theme={"dark"}
pi
```

At startup the extension loads the models your key can use from Requesty, so there is nothing to sync.

## Selecting a model

Run `/model` inside Pi and type `requesty` to filter the list to Requesty models. You can also pick one when starting Pi:

```txt theme={"dark"}
pi --provider requesty --model policy/opus-europe
```

The list follows your key's [approved models](https://docs.requesty.ai/features/approved-models.md) and includes:

* Discrete models, e.g. `anthropic/claude-opus-4-7`.
* Your organization's policies, e.g. `policy/opus-europe`.
* Managed models, e.g. `gpt-6.1-terra`, including `@eu` variants.

> [!NOTE]
>
> The extension sends `HTTP-Referer: https://pi.dev` and `X-Title: Pi` with every request. The referer is what enables Requesty's **automatic prompt caching** for Pi: on Anthropic models Requesty injects cache-control breakpoints so Pi's large system prompt and tool definitions are reused across turns, cutting cost by up to 90% on long conversations. See [Auto-Caching](https://docs.requesty.ai/features/auto-caching.md) for details.

## Optional settings

To change the provider settings, add a `requesty` entry to `~/.pi/agent/models.json`. Every field is optional; these are the defaults:

```json theme={"dark"}
{
  "providers": {
    "requesty": {
      "name": "Requesty",
      "baseUrl": "https://router.requesty.ai/v1",
      "api": "openai-completions"
    }
  }
}
```

> [!WARNING]
>
> Keep the `/v1` suffix on `baseUrl`. The extension loads the model list from `<baseUrl>/models`, so `https://router.requesty.ai` without `/v1` fails with `HTTP 404 Not Found`. If you switch to `api: "anthropic-messages"`, Pi appends `/v1/messages` itself, so that format needs `https://router.requesty.ai` without `/v1` and a manual `models` list.

To save the model list into `models.json`, for example to keep it when Requesty can't be reached, run `/requesty-models-sync` inside Pi and then `/reload`. The command keeps the file private to your user and never copies a key from `auth.json` into it.

## Troubleshooting

* **`startup discovery failed: HTTP 403 Forbidden`**: the key is wrong or revoked. Pi still starts, but without the Requesty model list.
* **No Requesty models in `/model`**: the extension found no key. Check that `auth.json` is in `~/.pi/agent` (or in `PI_CODING_AGENT_DIR`), and that `REQUESTY_API_KEY` is exported if you used `$REQUESTY_API_KEY`.

## Verifying the integration

Run a quick prompt inside Pi to confirm that requests are routed through Requesty. Then open the [Requesty analytics dashboard](https://app.requesty.ai/analytics) to verify the request was logged. Spend, latency, and token counts should appear within seconds.

For caching, send a couple of follow-up messages in the same session on an Anthropic model, then check the request in the dashboard. After the first turn you should see cached tokens greater than zero, confirming the prompt prefix is being reused.

## References

* [Pi homepage](https://pi.dev)
* [Requesty Pi Extension](https://github.com/requestyai/pi-requesty)
* [Requesty API Keys](https://app.requesty.ai/api-keys)
* [Requesty Model Library](https://app.requesty.ai/model-list)
* [Requesty Approved Models](https://docs.requesty.ai/features/approved-models.md)
* [Requesty Auto-Caching](https://docs.requesty.ai/features/auto-caching.md)


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