Claude Code Setup with a Cheap Claude API
Claude Code's official subscription is a flat monthly fee that adds up fast if you
use it daily. Point ANTHROPIC_BASE_URL at TokenProvider instead, pay per
token actually used, and typically save 50%+. Works with Sonnet 4,
Opus, and Haiku. 5 minutes end-to-end.
The core is two env vars: ANTHROPIC_BASE_URL=https://tokenprovider.store
and ANTHROPIC_API_KEY=your_proxy_key. Details below.
Prerequisites
- Node.js 18+ (
node -vto check) - A TokenProvider account with an API key
- Terminal access to set environment variables (macOS / Linux / Windows)
Step-by-step
-
Install Claude Code
Anthropic's official CLI via npm:
npm install -g @anthropic-ai/claude-codeclaude --versionshould print the installed version. -
Create an API key on TokenProvider
Sign up → API Keys → "Create key". Use one key per project so you can track usage and revoke independently.
The key is shown only once. Copy it immediately. Lost keys can't be recovered — only regenerated.
-
Set the environment variables
Pick temporary or persistent:
Temporary (current shell):
# macOS / Linux export ANTHROPIC_BASE_URL="https://tokenprovider.store" export ANTHROPIC_API_KEY="your_token_home_key" # Windows PowerShell $env:ANTHROPIC_BASE_URL = "https://tokenprovider.store" $env:ANTHROPIC_API_KEY = "your_token_home_key"Persistent (every new shell):
echo 'export ANTHROPIC_BASE_URL="https://tokenprovider.store"' >> ~/.zshrc echo 'export ANTHROPIC_API_KEY="your_key"' >> ~/.zshrc source ~/.zshrcOn bash, replace
~/.zshrcwith~/.bashrc. -
Verify
Inside any project:
cd your-project claudeFirst launch asks a few config questions (model preference, tool permissions) — defaults are fine. Then try "summarize this repo" — a normal response means the proxy is working.
-
Watch usage and billing
On the TokenProvider Usage page you'll see for each Claude Code request:
- Model used (Sonnet 4 / Opus / Haiku)
- Input + output tokens
- Cost charged
- Timestamp + request ID
Email alerts fire when balance drops below your threshold so you don't get cut off mid-task.
Common errors and fixes
| Error | Cause | Fix |
|---|---|---|
401 Unauthorized |
Wrong or unset API key | Check echo $ANTHROPIC_API_KEY returns your key |
ENOTFOUND tokenprovider.store |
No network or DNS failure | Confirm curl https://tokenprovider.store works |
429 Too Many Requests |
Too many calls in short window | Wait briefly or contact support for a limit raise |
402 Insufficient Balance |
Account out of funds | Top up from the dashboard (min $1) |
model not supported |
Requested a model not in pool | Run claude config and select Sonnet 4 / Opus / Haiku |
Advanced: per-project keys
Want different keys for different projects? Create a .env in the project
root or override inside your npm script:
# Project A's .env
ANTHROPIC_BASE_URL=https://tokenprovider.store
ANTHROPIC_API_KEY=sk-xxxxx-project-a
# Launch
source .env && claude
You can create multiple keys under the same TokenProvider account — each with its own billing view.
Why a proxy is cheaper than a subscription
Claude Code's official plan is a flat fee whether you use it all or not. A proxy pools many subscriptions and bills by the token you actually consume — no waste on idle months, no throttling on heavy months. Full breakdown: Claude Code Proxy vs Official Subscription.
Grab a key and cut your Claude Code bill in half
1-minute signup, $1 minimum top-up, pay per token, cancel anytime.
Sign up free → Already a memberFAQ
Do all Claude Code features work?
Yes — conversations, tool calls, file edits, shell execution, and MCP server configs all work unchanged.
How are sticky sessions handled?
Consecutive requests from the same key are routed to the same upstream account when possible, preserving conversation cache and saving more.
Can I use Cursor and Cline with the same key?
Yes. One key works across Cursor, Cline, and Claude Code simultaneously.
Team billing and invoices?
Yes. Export CSV statements from the dashboard; contact support for formal invoices.