Using Claude Code with abliteration.ai
Configure Claude Code to use abliteration.ai as its backend. Set ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY to route Claude Code through the abliteration.ai Messages API.
Claude Code is Anthropic's agentic coding tool that lives in your terminal. It uses the Anthropic Messages API under the hood.
Because abliteration.ai exposes an Anthropic-compatible /v1/messages endpoint, you can point Claude Code at abliteration.ai by setting two environment variables — no patches or forks required.
Quick start
# Set environment variables and launch Claude Code export ANTHROPIC_BASE_URL="https://api.abliteration.ai" export ANTHROPIC_API_KEY="ak_YOUR_API_KEY" claude
Service notes
- Pricing model: Usage-based pricing (~$5 per 1M tokens) billed on total tokens (input + output). See the API pricing page for current plans.
- Data retention: No prompt/output retention by default. Operational telemetry (token counts, timestamps, error codes) is retained for billing and reliability.
- Compatibility: OpenAI-style /v1/chat/completions request and response format with a base URL switch.
- Latency: Depends on model size, prompt length, and load. Streaming reduces time-to-first-token.
- Throughput: Team plans include priority throughput. Actual throughput varies with demand.
- Rate limits: Limits vary by plan and load. Handle 429s with backoff and respect any Retry-After header.
Prerequisites
#Before you start, make sure you have the following:
- An abliteration.ai account with credits. Purchase credits here.
- An API key (
ak_...) from your abliteration.ai dashboard. - Claude Code installed. Install with
npm install -g @anthropic-ai/claude-code.
Configuration
#Claude Code reads two environment variables to decide where to send requests:
| Variable | Value | Purpose |
|---|---|---|
ANTHROPIC_BASE_URL | https://api.abliteration.ai | Directs SDK requests to abliteration.ai instead of api.anthropic.com. |
ANTHROPIC_API_KEY | ak_YOUR_API_KEY | Your abliteration.ai API key, sent as a Bearer token. |
Persistent shell configuration
#Add the variables to your shell profile so they persist across terminal sessions.
# Add to ~/.bashrc, ~/.zshrc, or ~/.profile export ANTHROPIC_BASE_URL="https://api.abliteration.ai" export ANTHROPIC_API_KEY="ak_YOUR_API_KEY" # Reload your shell source ~/.zshrc # or source ~/.bashrc
Verify the connection
#Run a quick test to confirm Claude Code is talking to abliteration.ai.
# Quick connectivity test with curl
curl -s https://api.abliteration.ai/v1/messages \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ANTHROPIC_API_KEY" \
-d '{
"model": "abliterated-model",
"max_tokens": 64,
"messages": [{"role": "user", "content": "ping"}]
}' | python3 -m json.tool
# Then launch Claude Code — it will use the same env vars
claudeHow it works
#Claude Code uses the Anthropic Python/TypeScript SDK internally. The SDK reads ANTHROPIC_BASE_URL to override the default https://api.anthropic.com.
All requests flow through abliteration.ai's /v1/messages endpoint. Authentication, rate limits, credit metering, and content moderation work identically to direct API calls.
- Requests are authenticated with your
ak_API key. - Rate limits apply: 120 requests per 60-second window for API key callers.
- Credits are deducted per call based on total token usage.
- Streaming is used by default — Claude Code sends
stream: true.
Using with the Anthropic SDK directly
#The same environment variables work for any Anthropic SDK script, not just Claude Code.
import anthropic
# Reads ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY from env
client = anthropic.Anthropic()
message = client.messages.create(
model="abliterated-model",
max_tokens=1024,
messages=[
{"role": "user", "content": "Explain how abliteration works."}
],
)
print(message.content[0].text)Troubleshooting
#Common issues when connecting Claude Code to abliteration.ai:
- 401 Unauthorized — verify
ANTHROPIC_API_KEYis set and starts withak_. - Connection refused — confirm
ANTHROPIC_BASE_URLishttps://api.abliteration.ai(no trailing slash, no/v1suffix). - Model not found — Claude Code may request models like
claude-sonnet-4-20250514. The abliteration.ai backend maps all model names toabliterated-model. - 402 Insufficient Credits — top up from the pricing page.
- Rate limited (429) — wait for the
Retry-Afterperiod or reduce request frequency.
Common errors & fixes
- 401 Unauthorized: Ensure ANTHROPIC_API_KEY is exported and starts with ak_. Run: echo $ANTHROPIC_API_KEY
- Connection refused / timeout: Verify ANTHROPIC_BASE_URL is https://api.abliteration.ai with no trailing /v1.
- 402 Insufficient Credits: Purchase credits from the pricing page. Claude Code sessions can consume credits quickly.
- 429 Rate Limit: Claude Code sends many requests. Wait for the Retry-After period or slow down interactive use.