Cheap Claude Code API: 5 Legitimate Ways to Cut the Bill (2026 Prices)
The cheapest way to run Claude Code on the API is to combine three things: pick the smallest model that does the job, let prompt caching work, and buy the tokens at a discount. Search results for "cheap Claude Code API" are full of resold keys and "free API key" giveaways; this guide sticks to options you can verify and keep using. It is written by the team behind OpenLux, an API gateway, and uses list prices checked on November 22, 2026.
Start with the list price
Claude Code on an API key is billed per token. Anthropic's list prices per million tokens (MTok):
| Model | Input | Output | Cache hit | 5-minute cache write |
|---|---|---|---|---|
| Claude Opus 5.5 | $4 | $20 | $0.20 | $5 |
| Claude Sonnet 5.5 | $2 | $10 | $0.10 | $2.50 |
Source: Anthropic's pricing documentation. Everything below either moves you down this table or multiplies it by less than 1.
1. Use Sonnet for routine work
Sonnet 5.5 costs half of Opus 5.5 on both input and output. In Claude Code you can switch models with the /model command, so a practical habit is to keep Sonnet as the default for edits, tests and refactors, and switch to Opus only for hard design or debugging sessions. Every task you move from Opus to Sonnet costs half as much.
2. Let prompt caching do its job
Claude Code resends the same files and conversation context many times. When that context is cached, re-reading it costs the cache-hit price: $0.20 per MTok on Opus 5.5 instead of $4, one-twentieth of the normal input price. Writing to the cache costs a little more than normal input (1.25× for a 5-minute cache), so caching pays off when the same context is read again soon, which is exactly how coding sessions behave.
What breaks the cache is changing the start of the prompt. Long, stable sessions in one project cache well; constantly switching projects or clearing context throws the cache away.
3. Use the Batch API for work that can wait
Anthropic's Batch API gives a 50% discount on input and output for requests that are processed asynchronously, and the discount stacks with prompt caching. It does not fit interactive Claude Code sessions, but it does fit scripted jobs around them: bulk code review, generating tests across a repository, or documentation passes that can run overnight.
4. Buy tokens through a discounted gateway
A gateway sits between Claude Code and the model. Gateways differ in how they price:
- OpenRouter passes through the provider's price with no markup and charges 5.5% when you buy credits ($0.80 minimum; 5% for crypto), according to its FAQ. It is convenient, but for Claude it is never below list price.
- Discounted gateways sell the same models below list price. On OpenLux, each model's base price equals the list price, and each resource group multiplies it by a ratio. The three Claude Code groups on the pricing page on November 22, 2026:
| Group | Ratio | Trade-off stated on the pricing page |
|---|---|---|
| Claude-Code-1 | 0.17647 | Maximum discount, may queue at peak hours |
| Claude-Code-2 | 0.29412 | Moderate discount, moderate operational stability |
| Claude-Code-3 | 0.45 | Minor discount, excellent operational stability |
Per million tokens (input / output):
| Model | List | Claude-Code-1 | Claude-Code-2 | Claude-Code-3 |
|---|---|---|---|---|
| Claude Opus 5.5 | $4 / $20 | $0.71 / $3.53 | $1.18 / $5.88 | $1.80 / $9.00 |
| Claude Sonnet 5.5 | $2 / $10 | $0.35 / $1.76 | $0.59 / $2.94 | $0.90 / $4.50 |
The cheapest group can queue at peak hours. If a team is waiting on Claude Code during the workday, the 0.45 group is the safer pick and is still under half of list price.
5. Avoid "cheap keys" you cannot verify
Resold or shared API keys, "unlimited" keys and lifetime deals are common in search results. The usual problems: the key is revoked without notice, the model behind it is not the one advertised, or your code and prompts go through someone you know nothing about. Whatever you use, check that there is a public price list, a usage log that shows what each request cost, and a way to contact support. Top up a small amount first and test before you commit.
Putting it together: one month, three setups
Assume 10 million input tokens and 1 million output tokens in a month, ignoring caching so the numbers are easy to check:
| Setup | Cost |
|---|---|
| Opus 5.5 at list price | 10 × $4 + 1 × $20 = $60.00 |
| Sonnet 5.5 at list price | 10 × $2 + 1 × $10 = $30.00 |
| Sonnet 5.5 on Claude-Code-3 | $30 × 0.45 = $13.50 |
| Sonnet 5.5 on Claude-Code-2 | $30 × 0.29412 = $8.82 |
| Sonnet 5.5 on Claude-Code-1 | $30 × 0.17647 = $5.29 |
Caching lowers real bills further; this example leaves it out to keep the numbers easy to check.
Pointing Claude Code at OpenLux
- Create a key on the token page and choose its group. The key is billed at that group's price.
- Set two environment variables:
export ANTHROPIC_BASE_URL=https://api.openlux.ai
export ANTHROPIC_AUTH_TOKEN=<your OpenLux key>
- Run
claudeas usual.
- Do not add
/v1to the base URL. Claude Code appends/v1/messagesitself, and a doubled path returns 404. - To check the setup, call
GET https://api.openlux.ai/v1/modelswith the key. A model list means the URL and key are right; a 401 means the key is wrong or missing.
Top-ups start at $1 with no added fee. Payment: bank cards, Apple Pay, Google Pay, Alipay, WeChat Pay and crypto. Every request and its cost appear in the usage log.
See OpenLux Claude Code plans and setup →
FAQ
Is a Claude Pro or Max subscription cheaper than the API?
If your usage fits inside the plan's limits, a flat subscription is usually simpler. The API makes more sense when you keep hitting limits, run Claude Code in CI or scripts, or share access across a team.
Does a discounted gateway change how Claude Code works?
No. Only the base URL and key change. Groups differ in stability, which the pricing page states for each one.
Will these prices change?
List prices and group ratios can both change. Check the pricing page before you top up.