> ## 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 Claude Code with abliteration.ai

> Route Anthropic's Claude Code CLI through abliteration.ai by setting two auth variables and picking how to surface abliterated-model.

**To use Claude Code with abliteration.ai**, set `ANTHROPIC_BASE_URL` to `https://api.abliteration.ai` and `ANTHROPIC_AUTH_TOKEN` to your `ak_...` key, then run `claude`. Same Claude Code binary, same workflow, routed through abliteration.

Setup is three short steps: set the auth variables, pick how Claude Code should surface `abliterated-model`, then persist your config so you don't re-export it in every terminal.

## Install

<CodeGroup>
  ```sh macOS / Linux theme={"system"}
  curl -fsSL https://claude.ai/install.sh | bash
  ```

  ```powershell Windows theme={"system"}
  irm https://claude.ai/install.ps1 | iex
  ```
</CodeGroup>

## Step 1 — Set the auth variables

These two variables route Claude Code to abliteration.ai and authenticate the session. Every setup below needs them.

| Variable               | Value                         | What it does                                                                                                                                                                                      |
| ---------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ANTHROPIC_BASE_URL`   | `https://api.abliteration.ai` | Routes Claude Code to abliteration.ai instead of `api.anthropic.com`.                                                                                                                             |
| `ANTHROPIC_AUTH_TOKEN` | `ak_YOUR_API_KEY`             | Recommended. Sends your abliteration.ai key as the bearer `Authorization` header. `ANTHROPIC_API_KEY=ak_...` also works (sent as `x-api-key`); pick whichever your environment already has wired. |

## Step 2 — Surface `abliterated-model` in Claude Code

Claude Code's model picker is built around Claude model IDs. Two variable sets let it surface `abliterated-model` — pick whichever fits your workflow.

### Replace the default Opus / Sonnet / Haiku models

Override the model ID Claude Code sends for each default tier so the existing picker just works. Plain `claude` launches into `abliterated-model`.

```sh theme={"system"}
export ANTHROPIC_DEFAULT_OPUS_MODEL="abliterated-model"
export ANTHROPIC_DEFAULT_SONNET_MODEL="abliterated-model"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="abliterated-model"

claude
```

### Add `abliterated-model` to the picker

Keep the default Claude tiers intact and add `abliterated-model` as an extra picker entry you switch to explicitly.

```sh theme={"system"}
export ANTHROPIC_CUSTOM_MODEL_OPTION="abliterated-model"
export ANTHROPIC_CUSTOM_MODEL_OPTION_NAME="abliterated-model"

claude --model abliterated-model
```

You can also switch to it inside a session with `/model`.

## Step 3 — Persist your config

Exporting variables in every new terminal gets old. Pick one place to save them so Claude Code always picks them up.

| Location             | Where                     | Use when                                                                                     |
| -------------------- | ------------------------- | -------------------------------------------------------------------------------------------- |
| Claude Code settings | `~/.claude/settings.json` | You want the config scoped to Claude Code only.                                              |
| Shell profile        | `~/.zshrc` or `~/.bashrc` | You want the variables available to any Anthropic-compatible tool you run from the terminal. |

### Option A — `~/.claude/settings.json`

Claude Code reads an `env` block from its own settings file. Values here apply whenever you start `claude`.

```json theme={"system"}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.abliteration.ai",
    "ANTHROPIC_AUTH_TOKEN": "ak_YOUR_API_KEY",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "abliterated-model",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "abliterated-model",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "abliterated-model",
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "240000"
  }
}
```

### Option B — Shell profile

Append the same values to your shell profile so they export on every terminal launch.

```sh theme={"system"}
# Append to ~/.zshrc, ~/.bashrc, or ~/.profile
export ANTHROPIC_BASE_URL="https://api.abliteration.ai"
export ANTHROPIC_AUTH_TOKEN="ak_YOUR_API_KEY"
export ANTHROPIC_DEFAULT_OPUS_MODEL="abliterated-model"
export ANTHROPIC_DEFAULT_SONNET_MODEL="abliterated-model"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="abliterated-model"
export CLAUDE_CODE_AUTO_COMPACT_WINDOW="240000"

# Reload
source ~/.zshrc   # or source ~/.bashrc
```

## Context compaction

Claude Code automatically compacts long sessions by summarizing earlier turns while keeping recent context. abliteration.ai does not expose a separate compaction endpoint; Claude Code sends the summarization request through the same `ANTHROPIC_BASE_URL` and model configuration.

Set `CLAUDE_CODE_AUTO_COMPACT_WINDOW` from the model's context length. `abliterated-model` has a 256K context window (`context_length: 262144`), so `240000` leaves room for Claude Code's system prompt, tools, and the next response:

```json theme={"system"}
{
  "env": {
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "240000"
  }
}
```

<Note>
  Use the context length of the model you select. For example, use a larger value only when your selected model actually advertises a larger context window.
</Note>

## Headless mode

For CI/CD or scripts:

```sh theme={"system"}
claude --model abliterated-model -p "summarize README.md"
```

## Notes

* Policy rules attached to your API key apply to every Claude Code turn. See [Policy Gateway](/policy-gateway/overview).
