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

# Pi

> Route the Pi coding agent through Edgee to cut token costs and gain full observability, with one command.

Pi is a terminal coding agent installed from npm. Route it through Edgee to reduce token costs with lossless compression and gain full observability over every session.

## Edgee CLI setup (recommended)

The fastest way to connect Pi to Edgee is the CLI. It authenticates, registers an Edgee provider in your Pi config (populated from the live Edgee model catalog), and starts Pi.

<Steps>
  <Step title="Install the Edgee CLI">
    <Tabs>
      <Tab title="macOS / Linux">
        ```bash theme={"dark"}
        curl -fsSL https://edgee.ai/install.sh | bash
        ```
      </Tab>

      <Tab title="Homebrew (macOS)">
        ```bash theme={"dark"}
        brew install edgee-ai/tap/edgee
        ```
      </Tab>

      <Tab title="Windows (PowerShell)">
        ```powershell theme={"dark"}
        irm https://edgee.ai/install.ps1 | iex
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Install Pi">
    ```bash theme={"dark"}
    npm install -g @mariozechner/pi-coding-agent
    ```

    <Note>
      Pi **0.79.4 or newer** is required. Earlier versions read the credential differently and the gateway answers `401`.
    </Note>
  </Step>

  <Step title="Launch Pi through Edgee">
    ```bash theme={"dark"}
    edgee launch pi
    ```

    Token compression is enabled automatically. Pick an Edgee model from Pi's model picker, or pass one directly:

    ```bash theme={"dark"}
    edgee launch pi -- --model anthropic/claude-sonnet-5
    ```
  </Step>
</Steps>

After the session ends, the CLI prints a link to view token usage, compression savings, and cost breakdown in the Edgee Console.

The CLI adds a single `edgee` provider to `~/.pi/agent/models.json` (or your `PI_CODING_AGENT_DIR`, if set). It is additive: every other provider, model, and login you already had keeps working. Each model carries its context window and per-million-token rates from the Edgee catalog, so Pi's context gauge and session cost readout work instead of reporting every session as $0. Your API key is stored as a `$EDGEE\_API\_KEY\` reference and supplied at launch, never written to disk.

## Manual setup (advanced)

Prefer to configure Pi yourself? Add the provider to `~/.pi/agent/models.json` and declare the models you want:

```json theme={"dark"}
{
  "providers": {
    "edgee": {
      "name": "Edgee",
      "baseUrl": "https://edgee.io",
      "api": "anthropic-messages",
      "apiKey": "$EDGEE_API_KEY",
      "headers": {
        "x-edgee-api-key": "$EDGEE_API_KEY"
      },
      "models": [
        {
          "id": "anthropic/claude-sonnet-4-5",
          "name": "anthropic/claude-sonnet-4-5",
          "contextWindow": 1000000,
          "maxTokens": 64000,
          "cost": {
            "input": 3,
            "output": 15,
            "cacheRead": 0.3,
            "cacheWrite": 3.75
          }
        }
      ]
    }
  }
}
```

Then export your key from the [Edgee Console](https://www.edgee.ai) before running `pi`:

```bash theme={"dark"}
export EDGEE_API_KEY="<YOUR_EDGEE_API_KEY>"
```

<Note>
  `baseUrl` carries no `/v1` suffix: with `api: "anthropic-messages"`, Pi appends `/v1/messages` itself. A custom provider in Pi is defined by its models, so the `models` list cannot be empty. `edgee launch pi` writes all of this for you from the live catalog.
</Note>

## Benefits

<CardGroup cols={2}>
  <Card title="Cost reduction" icon="dollar-sign">
    Edgee's token compression reduces the tokens sent to and from the model, with no change to output quality.
  </Card>

  <Card title="Observability" icon="chart-line">
    Every request is logged in the Edgee Console with token counts, latency, and cost breakdowns.
  </Card>

  <Card title="Reliability" icon="shield-check">
    Automatic retry and fallback across providers keeps your sessions running even when a provider has issues.
  </Card>

  <Card title="One command" icon="terminal">
    No config to edit, the CLI wires everything up.
  </Card>
</CardGroup>

## Next Steps

* Learn more about the [Edgee CLI](/docs/features/cli) and its launch commands
* Set up [observability](/docs/features/observability) to monitor usage and costs
* Explore [retry and fallback](/docs/features/retry-and-fallback) for resilient routing
