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

Create a [Routing API key](/api-keys#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
        }
      ]
    }
  }
}
```

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

Pi sends Chat Completions requests through your organization's default router at `/v1`. It chooses from the router's current managed model set. Check **Activity** in the dashboard to see each selection.

## Configuration Reference

`"reasoning": false` keeps Pi from sending a fixed reasoning level; Dari still chooses the model's reasoning level for each request.

`"contextWindow": 1000000` matches the window shared by every model in the default router. Set this explicitly. Pi assumes `128000` for custom models, and it compacts once a conversation passes the context window minus a 16K reserve — so leaving it unset makes Pi summarize and discard history at roughly 112K tokens, even though the router can accept far more. Compaction loses detail and costs an extra model call, so an unnecessarily low value degrades long sessions.

`"sendSessionAffinityHeaders": true` makes Pi send a stable session identifier with every request. Dari uses it to keep all turns from one session under the same conversation on the **Activity** tab, including turns that arrive after compaction rewrites the message history. Without it, each request appears as its own conversation.

## Custom Routers

To use a different model set, edit the default router or [Create A Router](/router/create-a-router) with public or [Custom Models](/router/configure-models#custom-models). Set that router as the default to keep this same configuration, or point `baseUrl` at `https://routing.dari.dev/{router_id}/v1`.

A router accepts only as much context as its smallest model, so set `contextWindow` to the smallest window among the models you enable. Claude Haiku 4.5 accepts 200K, for example, and enabling it caps that router at `200000` no matter what the other models support. Query your router to read the value it reports:

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

The `context_window` field in the response is the value to copy into `models.json`.
