Claude Code
Run Claude Code on your cheapaimodel balance.
Claude Code talks to the Anthropic Messages API, so it only needs a base URL and a key.
Set it up
Add these to your shell profile (~/.zshrc, ~/.bashrc), then open a new terminal and run claude:
export ANTHROPIC_BASE_URL="https://api.cheapaimodel.ai"
export ANTHROPIC_AUTH_TOKEN="sk-..."ANTHROPIC_AUTH_TOKEN is sent as Authorization: Bearer. If you are signed in to a Claude subscription, run /logout inside Claude Code first so it uses the key.
Use settings.json instead
To keep the configuration with Claude Code rather than your shell, put it in ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.cheapaimodel.ai",
"ANTHROPIC_AUTH_TOKEN": "sk-..."
}
}Choosing models
Claude Code resolves its sonnet, opus and haiku aliases to model IDs; haiku also runs background tasks. Point the aliases at model IDs from the catalog that list /v1/messages:
export ANTHROPIC_DEFAULT_SONNET_MODEL="<model-id>"
export ANTHROPIC_DEFAULT_OPUS_MODEL="<model-id>"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="<model-id>"ANTHROPIC_MODEL sets the starting model; /model switches during a session.
Give Claude Code its own API key with a budget so an agent run can never spend more than you planned.