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

# Pi

> Run Pi through a Dari Router.

Install the [Dari CLI](https://docs.dari.dev/install-cli.md), then launch Pi through your organization's default router:

```bash theme={null}
dari pi
```

On first use, Dari signs you in if needed, creates and privately caches a Routing key, and starts the installed `pi` executable with an invocation-local Dari provider extension. Your existing Pi configuration is left intact. Gateway includes personal subscriptions, Dari managed billing, and bring-your-own provider keys; the \$20/month individual Autorouting plan unlocks the `dari/routing` router. Gateway serves any model enabled on your router: switch between them with `/model`, or request `dari/model/<model>` directly. Autorouting is the `dari/routing` option, which picks a model per request; it appears in `/model` only with the Autorouting plan, and the launcher starts on your router's first model without it. To subscribe, run `dari accounts` and choose **Get auto-routing** (or press `a` in the setup model picker); it opens the Usage page and picks up the plan once it is active.

On first launch, setup opens an **Accounts** page where you can connect one or more ChatGPT subscriptions, connect an API key (Vercel AI Gateway, OpenRouter, or direct provider keys), or choose Dari managed billing. Later launches go straight to the agent; run `dari accounts` to open the page again. In the model picker, each model shows what pays for it (a subscription, an API key, or Dari credits), preferring a subscription; press `s` to change it.

Every following argument is forwarded to Pi:

```bash theme={null}
dari pi -p "Review this repository"
dari pi --tools read,grep,find,ls
```

Pi sends Chat Completions requests through your organization's default router at `/v1`. The launcher configures a one-million-token context window and session-affinity headers, which keep long sessions from compacting too early and group all requests from one session under the same conversation in **Activity**. Dari chooses the model and reasoning level per request.

The launcher's extension also shows the routing state in Pi's footer: the model that served the turn, its thinking level when one is enabled, how many turns remain on the current routing lease (or `pinned` when [Session Pinning](https://docs.dari.dev/router/session-pinning.md) holds the model), and a link to the turn's conversation in Activity. Routing values come from the `X-Dari-Selected-Model`, `X-Dari-Thinking-Level`, `X-Dari-Lease-Turns-Remaining`, and `X-Dari-Session-Pinned` response headers, and the link from `X-Request-Id`. The lease header is present only while a lease is active.

Set `DARI_ROUTING_API_KEY` before launching to use an existing Routing key instead of the CLI-managed key.

## Manual Configuration

If you do not want to use the launcher, create a [Routing API key](https://docs.dari.dev/api-keys.md#create-a-routing-key):

```bash theme={null}
export DARI_ROUTING_API_KEY="dari_..."
```

Add this provider to `~/.pi/agent/models.json`:

```json theme={null}
{
  "providers": {
    "dari": {
      "baseUrl": "https://routing.dari.dev/v1",
      "api": "openai-completions",
      "apiKey": "$DARI_ROUTING_API_KEY",
      "compat": {
        "sendSessionAffinityHeaders": true
      },
      "models": [
        {
          "id": "dari/routing",
          "name": "Dari Router",
          "reasoning": false,
          "contextWindow": 1000000,
          "maxTokens": 128000
        }
      ]
    }
  }
}
```

```bash theme={null}
pi --provider dari --model dari/routing
```

`"reasoning": false` keeps Pi from sending a fixed reasoning level; Dari still chooses one per request. `"contextWindow"` sets the window the client assumes; the default router's models range from 200,000 to over 1,000,000 tokens. `"sendSessionAffinityHeaders": true` gives Dari a stable session identifier even after compaction rewrites message history.

To use a different model set, edit the default router or [Create A Router](https://docs.dari.dev/router/create-a-router.md) with public or [Custom Models](https://docs.dari.dev/router/configure-models.md#custom-models). To launch `dari pi` on that router, add **Pi** to its card on the **Routers** page or run `dari router assign-agent <router_id> pi`; the **X** on the card moves it back to the default router. With manual configuration instead, point `baseUrl` at `https://routing.dari.dev/{router_id}/v1`, and set `contextWindow` to the smallest window among its enabled models. Query its reported value with:

```bash theme={null}
curl -H "Authorization: Bearer $DARI_ROUTING_API_KEY" \
  https://routing.dari.dev/{router_id}/v1/models
```

## Setup Across Computers

The CLI loads your router configuration and subscription preferences from the server. A new computer reuses the existing models and thinking levels rather than applying launcher presets again. Subscription opt-outs are saved per organization, user, and launcher. Local files cache authentication and Routing keys, not setup completion.

Use the dashboard or `dari router update` to change the shared model configuration. Run `dari accounts` to manage connected accounts, see each plan's usage, or buy another.


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