Cheap Claude Code API: run Claude Code on a lower-cost key in 2 minutes
Claude Code is one of the best coding agents available, but it is hungry: every turn resends your project context. With the default API pricing, a busy day can burn through tens of dollars. This guide shows how to point Claude Code at apillms and pay a fraction of that — without changing how you work.
Why Claude Code is expensive
An agent turn includes the system prompt, tool definitions, the files it has read and the conversation so far. That can be 50k–150k tokens per turn. Most of it is identical to the previous turn — which is exactly what prompt caching is for. apillms bills cache reads at a small fraction of the input price (Claude Sonnet 5: about $0.046 per 1M tokens), so the repeated context becomes cheap.
Step 1 — get a key
Create an account, top up from $5 with PayPal or card, and copy your API key from the dashboard.
Step 2 — one-line setup
The Integrations page generates a command with your key already filled in. On macOS and Linux:
curl -fsSL "https://apillms.com/v1/setup-claudecode?key=YOUR_KEY&main=claude-sonnet-5" | bash
On Windows (PowerShell):
[Net.ServicePointManager]::SecurityProtocol='Tls12'; irm "https://apillms.com/v1/setup-claudecode?key=YOUR_KEY&main=claude-sonnet-5&os=windows" | iex
Or configure it by hand
export ANTHROPIC_BASE_URL=https://apillms.com export ANTHROPIC_AUTH_TOKEN=YOUR_KEY export ANTHROPIC_MODEL=claude-sonnet-5 export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5 claude
Which model should you use?
- claude-sonnet-5 — the everyday default: fast, strong at code, cheapest per task.
- claude-opus-5-5 — for hard refactors, architecture and debugging sessions. Switch inside Claude Code with
/model. - claude-haiku-4-5 — background tasks such as summaries and titles.
How much does it cost in practice?
Claude Code requests are mostly repeated context. Take an illustrative mix of 70% cache reads, 25% fresh input and 5% output on Claude Sonnet 5. At today's prices that blends to about $0.169 per 1M tokens, so a $20 pack covers roughly 118M tokens of agent work. Your own mix will differ; the dashboard shows the real tokens and cost of every request.
| Model | Input / 1M | Output / 1M | Cache read / 1M |
|---|---|---|---|
| claude-sonnet-5 | $0.274 | $1.37 | $0.046 |
| claude-opus-5-5 | $0.639 | $3.19 | $0.106 |
| claude-haiku-4-5 | $0.137 | $0.684 | $0.023 |
Prices update live from our API.
Tips to spend even less
- Keep sessions focused:
/clearbetween unrelated tasks so old context stops being resent. - Use
/compactwhen a session grows long. - Let Sonnet do routine work; reserve Opus for the hard problems.
Check that it works
Inside Claude Code run /status: the base URL should read https://apillms.com. Send a short prompt, then open the dashboard; the request appears with its model, tokens and cost within a few seconds.
Common problems
- "Invalid API key". The key was pasted with a space or into
ANTHROPIC_API_KEYwhileANTHROPIC_AUTH_TOKENholds an old value. Set one of them, not both. - Still billed by Anthropic. Claude Code was started from a shell that did not load the new variables. Open a new terminal or re-run the setup command.
- Model not found. Use the exact ids from the models page, such as
claude-sonnet-5. - Context too long. Long sessions are compacted automatically; you can also run
/compactyourself.
Use the same key elsewhere
The key also works in Cursor, Cline, Codex CLI, OpenCode and n8n, and with GPT, DeepSeek, Grok and Kimi models. See the Integrations page for each tool, or read why Claude Code uses so many tokens.
Try apillms
One API key for Claude, GPT, Grok, DeepSeek and Kimi. OpenAI- and Anthropic-compatible, prompt caching included, pay-as-you-go from $5 with PayPal or card. Credits never expire.
FAQ
Does Claude Code work with a third-party API?
Yes. Claude Code reads ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN; apillms implements the Anthropic Messages API it expects, including streaming, tools and prompt caching.
Can I use GPT or DeepSeek in Claude Code?
Claude Code is built for Claude models. For GPT, DeepSeek or Kimi use Codex, Cursor or Cline, which apillms also supports.
What happens when my credits run out?
Requests return an insufficient-credits error; top up in the dashboard and continue. Unused credits never expire.
Is this the official Claude Code?
Yes. You install Claude Code from Anthropic as usual; only the API endpoint and key change.