Running Claude Code pay-as-you-go: three setups and what each one bills A developer who operates ScaleMax, a prepaid API gateway, outlined three ways to bill Claude Code usage: a first-party Anthropic API key, a self-hosted proxy such as LiteLLM, or a hosted gateway. The writeup shows how to point Claude Code at an alternative endpoint via ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, and recommends setting ANTHROPIC_DEFAULT_HAIKU_MODEL to a cheap model for background work to cut costs. Disclosure: I run ScaleMax, a prepaid API gateway that is option 3 below. Claude Code is a terminal agent. It talks to whatever sits behind ANTHROPIC BASE URL using the Anthropic Messages API, so you have more billing choices than a monthly plan. If you want Claude models and you can pay by card in US dollars, this is the simplest option. You buy prepaid credit in the Anthropic Console, create a key, and Claude Code bills per token. Prompt caching is billed at the provider's cached rates, which matters a lot for an agent that resends the same context on every step. Run a proxy that speaks the Anthropic Messages API and routes to whichever providers you already pay for. You get full control and need one more service to operate. LiteLLM's docs have a Claude Code setup page. A hosted gateway gives you a key and a base URL and handles the routing. Use one when you want other model families in Claude Code, or a payment method the providers don't take. With ScaleMax, for example: export ANTHROPIC BASE URL="https://api.scalemax.pro" no /v1, Claude Code adds it export ANTHROPIC AUTH TOKEN="YOUR KEY" sent as Authorization: Bearer export ANTHROPIC MODEL="gpt-6.2-sol" any ID your key includes export ANTHROPIC DEFAULT HAIKU MODEL="gpt-6-luna" cheap model for background work claude To keep it, put the same values in the env block of ~/.claude/settings.json . Verify before a long session. A tiny request catches a wrong URL or key in seconds: curl https://api.scalemax.pro/v1/messages \ -H "Authorization: Bearer YOUR KEY" \ -H "anthropic-version: 2023-06-01" \ -H "content-type: application/json" \ -d '{"model":"gpt-6-luna","max tokens":16,"messages": {"role":"user","content":"Reply with K"} }' ANTHROPIC DEFAULT HAIKU MODEL at a cheap model cuts cost without changing your main model. | You want... | Use | |---|---| | Claude models, USD card, first-party terms | Anthropic API key | | Full control, already paying several providers | Self-hosted gateway | | Other model families in Claude Code, one prepaid key, UPI or card | Hosted gateway | I run ScaleMax. Setup guide: https://scalemax.pro/claude-code https://scalemax.pro/claude-code . Trial: $2 credit, no card.