# Running Claude Code pay-as-you-go: three setups and what each one bills

> Source: <https://dev.to/iron_man_bb32fc27aec35771/running-claude-code-pay-as-you-go-three-setups-and-what-each-one-bills-l11>
> Published: 2026-12-02 04:38:08+00:00

**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 the playbook "Controlling LLM cost": <https://wpnews.pro/playbooks/llm-cost>

**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.*
