Table of Contents
- What actually drives Claude Code API costs?
- Is it cheaper to run Claude Code on a Pro or Max plan or on API keys?
- Which tasks should go to Haiku or Sonnet instead of Opus?
- How often should you /clear or /compact a Claude Code session?
- Do MCP servers, skills and CLAUDE.md files inflate token usage?
- Does prompt caching work automatically in Claude Code?
- Can you set a spending cap and see live spend on Claude Code?
- What does a realistic Claude Code day cost before and after these fixes?
- Where does Agent 37 fit when you are cutting Claude Code costs?
- How did we check these numbers?
- How do you get started with Agent 37?
- What do people also ask?
Do not index
If you are working out how to reduce Claude Code API costs, start by shrinking what every turn sends to Anthropic: route routine work to Haiku or Sonnet with /model, run /clear between tasks, trim CLAUDE.md and MCP servers, and let the built-in prompt cache do its job, which in our worked example takes a 200-turn day from about $19.60 to about $6.90. For the hosting side of the bill, we recommend Agent 37, which runs Claude Code on a persistent, always-on cloud instance, with plans starting at $3.99 per month and your API key going straight to Anthropic. Agent 37 is not a token discounter and does not lower Anthropic's per-token rates; it removes the always-on VM cost that sits next to them. If your problem is purely tokens, start with the first seven fixes below; if you also pay for a server to keep Claude Code running, read the eighth.
Key takeaways
- Published Claude rates per million tokens: Haiku 4.5 is $1 in and $5 out, Sonnet 4.5 is $3 and $15, Opus 4.5 is $5 and $25, and Opus 4.1 is $15 and $75, so 100,000 input tokens on Sonnet cost $0.30. Confirm current numbers on Anthropic's pricing page before budgeting.
- Prompt cache reads bill at 10% of the input rate, which is why re-sent context is cheap and freshly read files are not; a 40,000-token file read for the first time is billed in full.
- In our worked example, /clear discipline, a slim CLAUDE.md and routing half of turns to Haiku 4.5 cut a 200-turn day from about $19.60 to about $6.90, roughly 65% less, or about $430 versus $150 over 22 working days.
- Max at $100 or $200 per month only wins when your metered API bill would consistently exceed its price; once you optimize below that line, API keys are cheaper.
- Agent 37 hosts Claude Code on a persistent instance from $3.99 per month, against near $25 a month for the smallest sensible hyperscaler VM, and your API keys go directly to Anthropic.

What actually drives Claude Code API costs?
Claude Code bills on tokens sent to and returned from the model, and input dominates because every turn resends the whole conversation, CLAUDE.md, every connected tool definition and every file read so far. Output tokens cost five times more each but are far smaller in volume.
The published rates matter because they set the multipliers for everything else. These are the per-million-token prices Anthropic lists; check Anthropic's pricing page for the current figures since Opus pricing has already changed between versions.
Model | Input per 1M tokens | Output per 1M tokens | Cache read per 1M tokens |
Claude Haiku 4.5 | $1 | $5 | $0.10 |
Claude Sonnet 4.5 | $3 | $15 | $0.30 |
Claude Opus 4.5 | $5 | $25 | $0.50 |
Claude Opus 4.1 | $15 | $75 | $1.50 |
So 100,000 input tokens cost $0.10 on Haiku 4.5, $0.30 on Sonnet 4.5 and $0.50 on Opus 4.5, and 100,000 output tokens cost $0.50, $1.50 and $2.50 respectively. One million Sonnet input tokens is $3.
To estimate a month, multiply turns per day by average context per turn, split that into cached and uncached shares, add output, then multiply by working days. The worked example later in this post does exactly that with real rates, and the same arithmetic works in any Claude token cost calculator. Trimming your Claude Code bill to under $7 a day frees budget for bigger life pivots, like retiring in cyprus as an american, where the 2026 permit and tax picture is now clearer than ever.
Is it cheaper to run Claude Code on a Pro or Max plan or on API keys?
Claude Pro at $20 per month includes Claude Code with tight usage limits, Max at $100 or $200 per month gives roughly 5x or 20x Pro usage, and API keys bill per token with no ceiling. Max is cheaper only when your metered bill would consistently exceed its price; occasional or well-optimized users usually pay less on the API.
The breakeven rule is simple. If your API spend lands above $100 a month every month, the $100 Max plan is cheaper; above $200, the $200 plan is. Our worked example shows a sloppy day pattern that would cost about $430 a month on the API, where Max wins, and an optimized pattern near $150, where API keys win.
Two caveats change the answer. Subscriptions carry session and weekly caps that Anthropic tightened in 2025, so heavy users can hit a wall mid-sprint, while the API never throttles you on budget grounds. And an always-on agent running scheduled jobs on a server is a natural fit for API keys, because the spend is predictable and visible per workspace. Confirm current plan terms on Anthropic's site before deciding.
Which tasks should go to Haiku or Sonnet instead of Opus?
Send mechanical work to Haiku 4.5: renames, test scaffolding, formatting, commit messages, log reading and simple docs. Keep Sonnet 4.5 as the default for everyday feature work and debugging. Reserve Opus for cross-file architecture, hard concurrency bugs and anything where a wrong answer costs more than the tokens saved. Switch mid-session with /model.
The ratios make the case. Haiku input is a third of Sonnet's price and Opus 4.5 input is five thirds of Sonnet's, so a 60,000-token turn costs $0.06, $0.18 or $0.30 before caching depending on the model. You can also start a session with the model flag, for example claude --model haiku, so a whole batch of chores never touches Opus.
Trust is the real constraint, not capability. The Stack Overflow 2025 Developer Survey found that 84% of developers use or plan to use AI tools while 46% distrust the accuracy of their output. Our rule: anything a cheap model does must be verified by a test or a diff review, which is also the work Haiku is good at generating.
How often should you /clear or /compact a Claude Code session?
Run /clear whenever you switch to an unrelated task, and /compact when the same task has produced a lot of noise such as test output and failed attempts. A practical rule: clear at every new ticket, compact once the context passes half the window.
The reason is linear. A turn carrying 150,000 tokens of context costs five times a turn carrying 30,000, and that premium repeats on every single message until you reset. Most of the Reddit threads about surprise Claude Code bills trace back to a single session kept open for days.
Two habits make resets painless. Give /compact instructions, such as compact but keep the failing test and the plan, so the summary preserves what matters. And when a task will outlive a session, ask Claude to write a short handoff note to a file in the repo; the next session reads a few hundred tokens instead of inheriting a 100,000-token conversation.

Do MCP servers, skills and CLAUDE.md files inflate token usage?
Yes. CLAUDE.md, the tool schemas of every connected MCP server and any auto-loaded skill or documentation are sent on every turn, which makes them the cheapest tokens to remove. A widely shared GitHub issue described one skill that pulled 200,000 tokens into every session before it was fixed.
Start by measuring. The /context command in Claude Code shows what is occupying the window, broken out by system prompt, tools, memory files and messages, so you can see whether a 30,000-token block of MCP tool definitions is riding along on every turn.
Then cut in order of size. Move long conventions out of CLAUDE.md into files the agent reads only when relevant; put large reference docs behind a skill whose body loads on demand rather than at startup; and disable MCP servers you are not using in this repo, since a server with dozens of tools can add tens of thousands of tokens by itself.
People also search for a .claudeignore file. Check the current Claude Code docs for what is officially supported in your version; the reliable equivalent is telling Claude in CLAUDE.md to stay out of node_modules, build output and generated files, and keeping those directories out of the repo in the first place.
Does prompt caching work automatically in Claude Code?
Prompt caching is on by default in Claude Code; there is nothing to configure. Cached reads bill at 10% of the input rate, cache writes cost 25% more than a normal input token, and the default cache expires after five minutes without a hit.
Anthropic's prompt caching documentation lists the mechanics: a minimum cacheable prefix of 1,024 tokens on Sonnet and Opus, higher on Haiku models, and a cache that is invalidated when anything earlier in the prompt changes. Editing CLAUDE.md or toggling an MCP server mid-session therefore forces a full-price rewrite of everything after it.
The Batch API is a different lever and it does not apply inside interactive Claude Code. Anthropic's batch processing docs describe a 50% discount on both input and output for asynchronous jobs that complete within 24 hours. That is the right tool for custom scripts: an overnight review of 300 files, bulk classification of issues, or generating docstrings across a repo, none of which need a live terminal.
Can you set a spending cap and see live spend on Claude Code?
Yes to both. Inside a session, /cost prints tokens and dollars consumed so far on API billing; the open-source ccusage tool reads Claude Code's local session logs and reports daily and monthly totals per model. In the Anthropic Console, workspace admins can set a monthly spend limit per workspace, and the Admin API exposes usage and cost reports for alerting.
ccusage on GitHub is the quickest way to answer the Reddit-style question of how much Claude Code cost you this week, because it works even when you never ran /cost. On Pro or Max, /cost does not show dollars, since usage is covered by the plan, so ccusage is also how subscribers check whether they are near the breakeven line.
For teams, create a separate workspace per project or per client, give each its own spend limit, and pull the Admin API usage report into whatever dashboard you already watch. A cap that pauses a runaway agent at $50 is worth more than any single prompt trick.

What does a realistic Claude Code day cost before and after these fixes?
A 200-turn day on Sonnet 4.5 with unmanaged context averaging 90,000 tokens per turn costs about $19.60, assuming 80% cache hits. Clearing between tasks, slimming CLAUDE.md and routing half the turns to Haiku 4.5 bring the same day to about $6.90, roughly $430 versus $150 over 22 working days.
Here is the arithmetic, using the rates in the table above and 1,500 output tokens per turn. We ignore the 25% cache write premium on first reads to keep it readable; it nudges both numbers up by a similar share.
Scenario | Input tokens | Cached share cost | Uncached share cost | Output cost | Day total |
Before: Sonnet only, 90K average context, never cleared | 18,000,000 | 14.4M at $0.30 = $4.32 | 3.6M at $3 = $10.80 | 300K at $15 = $4.50 | $19.62 |
After: 35K average context, half Sonnet | 3,500,000 | 2.8M at $0.30 = $0.84 | 0.7M at $3 = $2.10 | 150K at $15 = $2.25 | $5.19 |
After: 35K average context, half Haiku 4.5 | 3,500,000 | 2.8M at $0.10 = $0.28 | 0.7M at $1 = $0.70 | 150K at $5 = $0.75 | $1.73 |
The after total is $6.92 against $19.62, around 65% less. Notice where the savings come from: dropping average context from 90,000 to 35,000 tokens does most of the work, and model routing roughly halves what is left. Your own numbers will differ, but the shape is consistent with what people report in the GitHub and Reddit threads on Claude Code token cost.
Where does Agent 37 fit when you are cutting Claude Code costs?
Agent 37 does not change what Anthropic charges per token. It cuts the other line on the invoice: the always-on computer Claude Code runs on. Agent 37 plans start at $3.99 per month, your API key goes directly to Anthropic, and the repo, caches and sessions persist between runs, so you are not re-reading the codebase after every reconnect.
The always-on part is the hidden cost. An always-on worker on the smallest sensible hyperscaler VM lands near $25 a month before storage, schedulers and networking, which is the gap managed agent hosting closes. Claude Code hosting on a persistent Agent 37 instance is provisioned with one API call and keeps working after you close your laptop.
Plans start at $3.99 per month on a bring-your-own API keys model, and the agent sandbox pricing page lists the current plans. For a picture of what persistent per-session machines look like in practice, read the Vision case study.
Persistence also helps the token side indirectly. Because files and memory survive between runs on always-on agent hosting, you can schedule heavy work as one planned Opus job through the built-in task board instead of restarting a cold session and re-reading the repo several times a day. Keys never pass through Agent 37, so your Anthropic Console spend limits still apply unchanged.
How did we check these numbers?
We compared Anthropic's published per-token rates, prompt caching and batch processing documentation, and the public Pro and Max plan prices, then built the worked example from those rates with stated assumptions on turns, context size, cache hit rate and output length. Agent 37 figures come from its own pricing and solution pages.
How do you get started with Agent 37?
If you want Claude Code to keep running after you log off without adding a $25 VM to the bill, deploy it on a persistent instance and point it at your Anthropic key. Launch Claude Code on Agent 37, with plans from $3.99 per month, and bring the /clear, /model and caching habits from this guide with you.
What do people also ask?
Is it cheaper to use Claude Code with a Pro or Max subscription or with API keys?
It depends on your monthly metered spend. Pro is $20 per month with tight limits, Max is $100 or $200 per month with higher caps, and the API bills per token with no ceiling. If your API bill would consistently exceed $100 or $200, the matching Max plan is cheaper; if you optimize context and model choice so spend stays below that, API keys win and never throttle you. Confirm current plan terms on Anthropic's pricing page.
How much do 100,000 Claude tokens cost per model?
At published rates, 100,000 input tokens cost $0.10 on Haiku 4.5, $0.30 on Sonnet 4.5, $0.50 on Opus 4.5 and $1.50 on Opus 4.1. The same 100,000 tokens as output cost $0.50, $1.50, $2.50 and $7.50. Cache reads are 10% of the input price, so 100,000 cached Sonnet tokens cost $0.03. One million Sonnet input tokens is $3.
How do I see how many tokens and dollars a Claude Code session is consuming?
Run /cost inside the session to see tokens and dollars so far on API billing, and /context to see what is filling the window. For daily and monthly totals per model across all sessions, install the open-source ccusage tool from GitHub, which reads Claude Code's local logs and works for subscription users who see no dollar figure in /cost.
Do MCP servers, skills and CLAUDE.md files increase my Claude Code token usage?
Yes. All three are sent with every turn, so their size is multiplied by the number of messages in a session. A single skill was documented pulling 200,000 tokens into context, and an MCP server with many tools can add tens of thousands of tokens of schema. Keep CLAUDE.md short, connect only the servers a repo needs, and put long docs behind skills that load on demand.
Can I set a spending cap or budget alert on Claude Code API usage?
Yes. In the Anthropic Console, workspace admins can set a monthly spend limit per workspace, and the Admin API provides usage and cost reports you can wire into alerts. Create one workspace per project or client so a runaway agent in one place cannot drain the whole budget. Hosting Claude Code on Agent 37 does not change this, because API keys go directly to Anthropic and the Console limits still apply.
