Claude Code + OpenCompress
Two env vars. Zero code changes. Use your own Anthropic API key and save 40-60% on every Claude Code session.
API key users only — Works with Claude Code API plan (ANTHROPIC_API_KEY). Does not work with Pro/Max/Team subscriptions (OAuth, can't redirect).
Zero registration. Point Claude Code to OpenCompress with your own Anthropic API key. Your key is forwarded directly — we never store it.
# Add to your shell profile (~/.zshrc or ~/.bashrc)
export ANTHROPIC_BASE_URL=https://www.opencompress.ai/api
export ANTHROPIC_API_KEY=sk-ant-xxx # your Anthropic API key
# Reload and start
source ~/.zshrc && claudeNote: Free tier: 25 req/min. For higher limits and usage stats, see Step 4.
All requests are compressed automatically before reaching Anthropic. Same Claude experience, 40-60% fewer input tokens.
Note: Compression is transparent — tool calls, streaming, extended thinking all work normally.
Test from the terminal to confirm compression is active:
# Quick test — check response headers for compression stats
curl https://www.opencompress.ai/api/v1/messages \
-H "x-api-key: sk-ant-YOUR_KEY" \
-H "anthropic-version: 2025-01-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-20250514",
"max_tokens": 100,
"messages": [{"role": "user", "content": "Say hello"}]
}' -v 2>&1 | grep -i x-opencompressSign up for a usage dashboard, compression stats, 120 req/min, and $10 free credit. Configure your upstream Anthropic key in the dashboard, then use your OpenCompress key with Claude Code.
# 1. Sign up at https://www.opencompress.ai/dashboard
# 2. Create an API key (sk-occ-xxx) and set your upstream Anthropic key in dashboard
# Add to your shell profile (~/.zshrc or ~/.bashrc)
export ANTHROPIC_BASE_URL=https://www.opencompress.ai/api
export ANTHROPIC_API_KEY=sk-occ-xxx # your OpenCompress key from dashboard
# Reload and start
source ~/.zshrc && claudeHow It Works
OpenCompress sits between Claude Code and the Anthropic API.
Claude Code
│ POST /v1/messages (Anthropic native format)
▼
OpenCompress (www.opencompress.ai/api)
│ 1. Compress system prompt + conversation history
│ 2. Forward compressed request to api.anthropic.com
│ 3. Stream response back unchanged
▼
Anthropic API
│ Processes fewer input tokens → lower cost
▼
Claude Code
│ Receives normal response (streaming, tools, etc.)FAQ
Common questions about using OpenCompress with Claude Code.
Do you store my API key?
No. Your key is forwarded directly to Anthropic in memory and never persisted.
Does streaming work?
Yes. Anthropic SSE events are passed through unchanged. Streaming, tool use, and extended thinking all work normally.
What about tool calls?
Tool definitions and tool results are forwarded as-is. Only text content in messages is compressed.
Why doesn't it work with Pro/Max subscriptions?
Subscription plans authenticate via Anthropic's OAuth. There's no environment variable to redirect the traffic through a proxy.
What's the rate limit?
Free tier: 25 req/min (no registration). Registered: 120 req/min + usage dashboard + $10 free credit.
Can I use this with other Claude tools?
Any tool that supports ANTHROPIC_BASE_URL will work — Claude Code, custom scripts, Anthropic SDK apps.
Start Saving
Every Claude Code session gets cheaper. Two env vars, zero code changes.