cd /news/ai-tools/running-claude-code-pay-as-you-go-th… · home › topics › ai-tools › article
[ARTICLE · art-179950] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=· neutral

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.

recommendation

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.

more in playbook: Controlling LLM cost
by read2 min views13 publishedDec 2, 2026

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. Trial: $2 credit, no card.

── more in #ai-tools 4 stories · sorted by recency
── more on @claude code 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/running-claude-code-…] indexed:0 read:2min 2026-12-02 · —