The ANTHROPIC_BASE_URL Trick: One Env Var, 80% Off Every Anthropic Tool
ANTHROPIC_BASE_URL is the most underrated env var in AI tooling. Set it once and every Anthropic-compatible tool — Claude Code, Cline, OpenClaw, Aider, Continue — runs through your custom endpoint at 80% off.
The most underrated env var in AI tooling
If you've used Claude Code, you might know ANTHROPIC_BASE_URL. If you've used Cline, OpenClaw, Aider, OpenCode, Goose, or any other tool built on the Anthropic Python or Node SDK — you can use it there too. The same single environment variable redirects every Anthropic-compatible tool on your machine to a custom endpoint.
Set it once at the shell level, and every Claude tool you launch from that shell routes through your override.
What it does
ANTHROPIC_BASE_URL overrides the default https://api.anthropic.com that the Anthropic SDK uses. The SDK reads it on initialization. So does every tool that uses the SDK.
The same trick exists for OpenAI: OPENAI_BASE_URL. And for Google AI Studio (less consistent across tools): GOOGLE_BASE_URL or per-tool config.
Set it once, save everywhere
In your shell profile (~/.zshrc, ~/.bashrc, ~/.config/fish/config.fish):
export ANTHROPIC_BASE_URL="https://claudeapi.cheap/api/proxy"
export ANTHROPIC_API_KEY="sk-cc-your-key-here"
# Or for tools that use AUTH_TOKEN instead of API_KEY:
export ANTHROPIC_AUTH_TOKEN="sk-cc-your-key-here"Reload your shell (source ~/.zshrc or open a new terminal). From now on, every Anthropic-SDK-based tool launched from that shell uses the override.
What this affects
A non-exhaustive list of tools that pick up ANTHROPIC_BASE_URL:
anthropic (Python) or @anthropic-ai/sdk (Node).base_url argument.It does NOT affect:
Why this works (for the curious)
The Anthropic SDK's source code has a check like process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com" at construction time. The SDK then hits whatever URL is configured. As long as the URL responds with the same JSON shape Anthropic returns, every downstream call works.
claudeapi.cheap is a strict superset of the Anthropic API — same routes, same auth, same request shape, same response shape, same SSE event types for streaming. We strip vendor-fingerprint headers (so the upstream identity stays hidden) but never modify content.
Same trick for OpenAI and Gemini
export OPENAI_API_KEY="sk-cc-your-key-here"
export OPENAI_BASE_URL="https://claudeapi.cheap/api/proxy/v1"The same sk-cc-... key works for both providers. Our /v1/chat/completions route also serves Gemini models — pick gemini-3-pro-preview or gemini-2.5-flash as the model id.
Result: one environment, three vendors, every tool 80% off.
Project-scoped overrides
Don't want this active everywhere? Use direnv to scope env vars to specific directories:
# In your project's .envrc:
export ANTHROPIC_BASE_URL="https://claudeapi.cheap/api/proxy"
export ANTHROPIC_API_KEY="sk-cc-your-key-here"Then direnv allow once. Every shell entering that directory inherits the override; every shell elsewhere uses Anthropic Direct.
Verifying the override works
Quick test from any shell:
echo $ANTHROPIC_BASE_URL
# → https://claudeapi.cheap/api/proxy
curl -s $ANTHROPIC_BASE_URL/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-haiku-4-5","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'
# → JSON response with id starting chatcmpl- or msg_If the JSON comes back, your env is set correctly and every tool that respects the env will inherit.
Get started
Sign up free, grab an sk-cc-... key, paste two export lines into your shell profile. Every Anthropic tool on your machine is now 80% cheaper without changing a single line of tool code.