{"slug": "running-claude-code-pay-as-you-go-three-setups-and-what-each-one-bills", "title": "Running Claude Code pay-as-you-go: three setups and what each one bills", "summary": "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.", "body_md": "**Disclosure:** I run ScaleMax, a prepaid API gateway that is option 3 below.\n\nClaude 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.\n\nIf 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.\n\nRun 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.\n\nA 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.\n\nWith ScaleMax, for example:\n\n```\nexport ANTHROPIC_BASE_URL=\"https://api.scalemax.pro\"   # no /v1, Claude Code adds it\nexport ANTHROPIC_AUTH_TOKEN=\"YOUR_KEY\"                  # sent as Authorization: Bearer\nexport ANTHROPIC_MODEL=\"gpt-6.2-sol\"                    # any ID your key includes\nexport ANTHROPIC_DEFAULT_HAIKU_MODEL=\"gpt-6-luna\"       # cheap model for background work\nclaude\n```\n\nTo keep it, put the same values in the `env` block of `~/.claude/settings.json`.\n\n**Verify before a long session.** A tiny request catches a wrong URL or key in seconds:\n\n```\ncurl https://api.scalemax.pro/v1/messages \\\n  -H \"Authorization: Bearer YOUR_KEY\" \\\n  -H \"anthropic-version: 2023-06-01\" \\\n  -H \"content-type: application/json\" \\\n  -d '{\"model\":\"gpt-6-luna\",\"max_tokens\":16,\"messages\":[{\"role\":\"user\",\"content\":\"Reply with K\"}]}'\n```\n\n`ANTHROPIC_DEFAULT_HAIKU_MODEL` at a cheap model cuts cost without changing your main model.\n| You want... | Use | \n|---|---|\n| Claude models, USD card, first-party terms | Anthropic API key | \n| Full control, already paying several providers | Self-hosted gateway | \n| Other model families in Claude Code, one prepaid key, UPI or card | Hosted gateway | \n\n*I run ScaleMax. Setup guide: [https://scalemax.pro/claude-code](https://scalemax.pro/claude-code). Trial: $2 credit, no card.*", "url": "https://wpnews.pro/news/running-claude-code-pay-as-you-go-three-setups-and-what-each-one-bills", "canonical_source": "https://dev.to/iron_man_bb32fc27aec35771/running-claude-code-pay-as-you-go-three-setups-and-what-each-one-bills-l11", "published_at": "2026-12-02 04:38:08+00:00", "updated_at": "2026-12-02 04:43:31.784057+00:00", "lang": "en", "topics": ["ai-tools", "large-language-models", "ai-agents", "developer-tools"], "entities": ["Claude Code", "Anthropic", "ScaleMax", "LiteLLM"], "also_reported_by": [], "takeaway": "Pointing Claude Code at a proxy or gateway through ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, then setting ANTHROPIC_DEFAULT_HAIKU_MODEL to a cheap model, lowers cost for background work without changing the main model.", "recommendation": {"advice": "Set ANTHROPIC_DEFAULT_HAIKU_MODEL to a cheap model and verify your base URL and key with a small curl request before starting a long Claude Code session.", "playbook": "llm-cost", "playbook_url": "https://wpnews.pro/playbooks/llm-cost"}, "alternates": {"html": "https://wpnews.pro/news/running-claude-code-pay-as-you-go-three-setups-and-what-each-one-bills", "markdown": "https://wpnews.pro/news/running-claude-code-pay-as-you-go-three-setups-and-what-each-one-bills.md", "text": "https://wpnews.pro/news/running-claude-code-pay-as-you-go-three-setups-and-what-each-one-bills.txt", "jsonld": "https://wpnews.pro/news/running-claude-code-pay-as-you-go-three-setups-and-what-each-one-bills.jsonld"}}