> ## 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. 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.

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

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

        # Accept the alias prompt (recommended).
        # If skipped: edgee alias
        # Reopen your terminal afterward.
        ```
      </Tab>

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

        # Enable aliases (recommended).
        edgee alias
        # Reopen your terminal afterward.
        ```
      </Tab>

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

        # Enable aliases (recommended).
        edgee alias
        # Reopen your terminal afterward.
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Launch Pi through Edgee">
    Choose how you want to launch. Both options route requests through Edgee.

    <Tabs>
      <Tab title="With aliases (recommended)">
        With aliases installed in the previous step, use your usual command:

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

        The alias runs `edgee launch` for you, so requests go through Edgee.
      </Tab>

      <Tab title="Without aliases">
        Launch explicitly through Edgee each time:

        ```bash theme={"dark"}
        edgee launch pi
        ```

        No alias setup is required.
      </Tab>
    </Tabs>

    If you are not signed in, Edgee starts sign-in automatically at launch. Follow the prompts and select your organization when asked.

    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)

### Get your coding-agent key

Manual setup uses the key of your enrolled **Pi** agent, **not a standard API key** created for LLM Router applications.

1. Open the [Edgee Console](https://www.edgee.ai) and select your organization.
2. In the header, click **Set up coding agent** or **+**, select **Pi**, and click **Enroll**. If your agent is already enrolled, use its existing icon.
3. Click the agent's icon, then **Advanced settings → Advanced**.
4. Under **Edgee API key (for manual setup)**, click **Reveal key**, then the copy icon.

Use this key wherever the configuration below shows `<YOUR_CODING_AGENT_KEY>`.

### Configure Pi

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_CODING_AGENT_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>

## 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

## Verify the connection

Send one request from the configured client, then open **Logs** in the same Edgee organization. Check the served model, provider, and key. For a CLI-launched coding agent, also inspect its session report.

If the request is missing, check that you launched through Edgee or saved the client’s gateway URL and coding-agent key. If it appears with an error, inspect the error before changing settings. See [Troubleshooting](/docs/troubleshooting) and [Gateway errors](/docs/llm-router/api-reference/errors).
