Docs

Claude Code custom Anthropic gateway

Route Claude Code through abliteration.ai as an Anthropic Messages gateway. Set the base URL and one auth variable, pick a model-selection style, and persist your config via ~/.claude/settings.json or your shell profile.

Updated 2026-08-04

This guide routes Claude Code through abliteration.ai as an Anthropic-compatible gateway. Claude Code is Anthropic's terminal coding agent; abliteration.ai exposes /v1/messages and /v1/messages/count_tokens, so it works as a drop-in backend with environment-variable configuration only.

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

# Quickest path: tier mapping + plain "claude" launch
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"

claude

Prerequisites

Before you start:

Step 1 — Set the auth variables

Set ANTHROPIC_BASE_URL, then choose one auth variable. ANTHROPIC_AUTH_TOKEN is recommended for Claude Code; ANTHROPIC_API_KEY also works with your ak_ key.

VariableValueWhat it does
ANTHROPIC_BASE_URLhttps://api.abliteration.aiRoutes Claude Code to abliteration.ai instead of api.anthropic.com.
ANTHROPIC_AUTH_TOKENak_YOUR_API_KEYSends your abliteration.ai key as the bearer Authorization header. Recommended for Claude Code.
ANTHROPIC_API_KEYak_YOUR_API_KEYAlso supported for Anthropic-compatible tools that send API keys as x-api-key.

Step 2 — Pick a model-selection style

Claude Code's model picker is built around Claude model IDs. Two variable sets tell it how to surface abliterated-model. Choose one.

StyleVariables to setLaunch command
A · Tier mapping
Recommended. Every default Claude tier (Opus, Sonnet, Haiku) is silently backed by abliterated-model, so the normal picker just works.
ANTHROPIC_DEFAULT_OPUS_MODEL=abliterated-model
ANTHROPIC_DEFAULT_SONNET_MODEL=abliterated-model
ANTHROPIC_DEFAULT_HAIKU_MODEL=abliterated-model
claude
B · Custom model option
Keeps Claude default models intact and adds abliterated-model as an extra picker entry you switch to explicitly.
ANTHROPIC_CUSTOM_MODEL_OPTION=abliterated-model
ANTHROPIC_CUSTOM_MODEL_OPTION_NAME=abliterated-model
claude --model abliterated-model
(or switch with /model)

Step 3 — Persist your config

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

LocationWhereUse when
Claude Code settings~/.claude/settings.jsonYou want the config scoped to Claude Code only.
Shell profile~/.zshrc or ~/.bashrcYou want the same variables available to any Anthropic-compatible tool you run from the terminal.

Example — ~/.claude/settings.json

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

{
  "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"
  }
}

Example — shell profile

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

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

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

Verify the connection

Hit /v1/messages directly with curl. If this returns a JSON response, Claude Code will too.

curl -s https://api.abliteration.ai/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -d '{
    "model": "abliterated-model",
    "max_tokens": 64,
    "messages": [{"role": "user", "content": "ping"}]
  }' | python3 -m json.tool

How it works

Claude Code speaks the Anthropic Messages API. Setting ANTHROPIC_BASE_URL redirects that traffic to abliteration.ai. ANTHROPIC_AUTH_TOKEN authenticates as a bearer token; ANTHROPIC_API_KEY is also accepted for ak_ keys via x-api-key.

Troubleshooting

FAQ

Frequently asked questions.

Can I use Claude Code with abliteration.ai?

Yes. Claude Code supports Anthropic Messages-compatible gateways. Point ANTHROPIC_BASE_URL at https://api.abliteration.ai and authenticate with your abliteration.ai API key.

Should I use ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN?

ANTHROPIC_AUTH_TOKEN is still the clearest Claude Code setup because it sends Authorization: Bearer. ANTHROPIC_API_KEY also works when the value is your abliteration.ai ak_ key; it is sent as x-api-key for Anthropic SDK compatibility.

How do I make Claude Code use abliterated-model?

Pick one of two styles. <strong>Tier mapping</strong> (recommended) sets ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, and ANTHROPIC_DEFAULT_HAIKU_MODEL to <code>abliterated-model</code> so you can just run <code>claude</code>. <strong>Custom model option</strong> sets ANTHROPIC_CUSTOM_MODEL_OPTION and you launch with <code>claude --model abliterated-model</code>.

Where should I save the config so it persists?

Either place works. <code>~/.claude/settings.json</code> scopes the config to Claude Code only. Your shell profile (<code>~/.zshrc</code>, <code>~/.bashrc</code>) makes the same variables available to any other Anthropic-compatible tool you run from the terminal.

Does streaming work?

Yes. Claude Code uses Anthropic Messages-style SSE streaming, and abliteration.ai's <code>/v1/messages</code> endpoint supports it natively.

How much does it cost?

Usage is billed via abliteration.ai credits at approximately $3 per 1 million tokens. Claude Code sessions can consume credits quickly because they involve many round trips, context reads, and streamed turns.