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

# Use Pi with abliteration.ai

> Use the Pi coding agent with abliteration.ai through a custom OpenAI-compatible provider, with session affinity enabled for prompt-cache routing.

[Pi](https://pi.dev) is a terminal coding agent. Configure abliteration.ai as a custom OpenAI-compatible provider and enable Pi's session-affinity headers so requests from the same conversation are routed together for better prompt-cache reuse.

## Install

Pi requires Node.js 22.19 or later.

```sh theme={"system"}
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
```

## Set your API key

Get an `ak_...` key from the [console](https://abliteration.ai/console), then export it in your shell:

```sh theme={"system"}
export ABLIT_KEY="ak_YOUR_API_KEY"
```

## Configure the provider

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

```json theme={"system"}
{
  "providers": {
    "abliteration": {
      "baseUrl": "https://api.abliteration.ai/v1",
      "apiKey": "$ABLIT_KEY",
      "api": "openai-completions",
      "compat": {
        "sendSessionAffinityHeaders": true
      },
      "models": [
        {
          "id": "abliterated-model-large-v2",
          "name": "Abliterated Model Large V2",
          "reasoning": true,
          "input": ["text"],
          "contextWindow": 1000000,
          "maxTokens": 999990,
          "cost": {
            "input": 5,
            "output": 5,
            "cacheRead": 0.5,
            "cacheWrite": 5
          }
        },
        {
          "id": "abliterated-model",
          "name": "Abliterated Model",
          "reasoning": true,
          "input": ["text", "image"],
          "contextWindow": 262144,
          "maxTokens": 262134,
          "cost": {
            "input": 3,
            "output": 3,
            "cacheRead": 0.3,
            "cacheWrite": 3
          }
        }
      ]
    }
  }
}
```

<Warning>
  Keep `sendSessionAffinityHeaders` enabled. Pi auto-detects this behavior only for known providers, so the custom abliteration.ai provider must enable it explicitly. Pi then sends its session ID in `x-session-affinity`, which abliteration.ai uses as a cache-routing hint. See [Pi's provider compatibility reference](https://github.com/earendil-works/pi/blob/d12cd92e45e308d4af000554292165ef1984253b/packages/coding-agent/docs/models.md?plain=1#L432) and [prompt caching on abliteration.ai](/capabilities/prompt-caching).
</Warning>

Do not replace this setting with one static custom header. Pi derives a stable value for each session, keeping unrelated conversations in separate affinity groups.

## Start Pi

Run `pi`, enter `/model`, and select the **abliteration** provider and your preferred model. Use **Abliterated Model** when you need image input; **Abliterated Model Large V2** is text-only.
