You can estimate any Claude Code bill with one formula. Every request bills in two directions: the tokens Claude reads (input) and the tokens Claude writes (output), and a cached portion of the input reads at a cut rate. Multiply each by its per-million-token price and add them up:

cost = (input tokens / 1,000,000 x input price)
     + (cached tokens / 1,000,000 x cache read price)
     + (output tokens / 1,000,000 x output price)

Anthropic publishes the per-million-token rates, and they span a 10x spread across the current lineup (from the official pricing page):

Model Input per MTok Output per MTok Cache read per MTok
Claude Haiku 4.5 $1 $5 $0.10
Claude Sonnet 5 $2 $10 $0.20
Claude Sonnet 4.6 $3 $15 $0.30
Claude Opus 5 $5 $25 $0.50
Claude Fable 5 $10 $50 $1.00

Two ratios in that table drive almost every bill. Output costs five times input on every tier, and a cache read costs a tenth of standard input on every tier.

The verdict: the model you pick dominates the math, and the way you manage context decides how much you pay for it. CostGoat's own cost bands give useful anchors: personal projects typically land between $10 and $50 a month, small apps between $50 and $200, production apps between $200 and $1,000, and large enterprise workloads above $1,000.

Read on for the copy-ready calculator and the worked examples, then five sourced ways to pull the number down. If you only want the full pricing landscape and the subscription-versus-API decision, the complete Claude Code cost breakdown covers that in depth.

What the per-token numbers actually mean

The rate table above comes from Anthropic's official pricing documentation. Three patterns matter more than the exact dollars.

Output is the expensive direction. Every current Claude model charges five times as much for output as for input. The tokens you pay the most for are the ones Claude writes back, which is why long, unconstrained responses inflate a bill faster than anything you read into the model. Thinking tokens, the internal reasoning Claude produces on complex tasks, bill at the output rate too.

A cache read is a tenth of standard input. When Claude Code re-reads the same codebase context, system prompt, or conversation history, the API serves it from cache at 10% of the standard input price. Anthropic prices a cache write at 1.25x for a 5-minute lifetime and 2x for a 1-hour lifetime, and reads at 0.1x either way. The trade works out simply: a 5-minute cache pays off after a single read, and a 1-hour cache pays off after two reads. CostGoat frames the same mechanic as up to 90% savings on cached input. For agentic coding, where the same context loads over and over, caching is the difference between paying full input price on every request and paying a tenth of it.

Prices move. Two tiers carry rates that will not last. CostGoat notes that Sonnet 5 runs an introductory $2 input / $10 output through August 31, 2026, before settling at $3 / $15. Anthropic lists Sonnet 5 at the introductory figure on its official page today. Anthropic updates the live card at claude.com/pricing, so check that page for the current rates before you commit a budget, and treat the table above as the structure rather than a quote.

One more caution from the top SERP calculator, llm-prices.com: models use different tokenizers, so a direct token-for-token price comparison across providers is never exact. The same English sentence can tokenize to different counts on different models. Within a single provider the formula holds precisely; across providers treat comparisons as approximate.

Get your real token counts before you estimate

A formula is only as good as its inputs, and you do not have to guess the token counts. Claude Code has the telemetry built in.

Run /usage inside a session. The Session block shows the token breakdown for your current session: input, output, cache reads, and cache writes, with a dollar figure. Claude Code computes that figure locally from token counts priced at standard list rates, so it ignores promotional pricing and contracted discounts and can differ from your actual bill. For authoritative billing, use the Usage page in the Claude Console.

Run /insights for a broader read on how you work: what you spend time on and where friction shows up, rather than a raw token tally. On a subscription plan, /usage also flags behaviors that account for 10% or more of your recent usage, such as long context or cache misses, each with a tip to reduce it. When the telemetry starts telling you which behavior eats your allowance, that is the moment the estimate turns into a target.

If you need to translate an English description into a token count before you have real data, use Anthropic's rule of thumb: one token is roughly 0.75 words in English, or about four characters. Starting there gets you within the right order of magnitude for planning.

Worked example: what a single coding hour costs

Anthropic publishes a clean worked example in its own pricing docs, so start there and verify your arithmetic against it.

A one-hour coding session on Claude Opus 5 that consumes 50,000 input tokens and 15,000 output tokens:

Line item Calculation Cost
Input tokens 50,000 x $5 / 1,000,000 $0.25
Output tokens 15,000 x $25 / 1,000,000 $0.375
Session runtime 1.0 hour x $0.08 $0.08
Total $0.705

The same hour with prompt caching active, where 40,000 of the 50,000 input tokens are cache reads:

Line item Calculation Cost
Uncached input 10,000 x $5 / 1,000,000 $0.05
Cache read 40,000 x $5 x 0.1 / 1,000,000 $0.02
Output 15,000 x $25 / 1,000,000 $0.375
Session runtime 1.0 hour x $0.08 $0.08
Total $0.525

Both figures are Anthropic's own, straight from the pricing documentation. Note what changes: the input line drops from $0.25 to $0.07 when the context is cached, while output, the expensive direction, stays put. The session runtime line is specific to Claude Managed Agents, which bill $0.08 per session-hour in addition to tokens. On the Claude API that runtime line does not apply, so your total reads even lower.

Worked example: what a month of development costs

Now extend that single-session arithmetic to a realistic month, with the assumptions labeled so you can swap in your own numbers.

Assumptions: a developer runs ten coding sessions per day for 21 working days in a month. Each session loads a 50,000-token codebase context, 90% of which is served from cache, and generates 8,000 output tokens. No batch discount applies, and no usage credits are purchased.

First on Claude Opus 5 ($5 input, $25 output, $0.50 cache read per million tokens):

Line item Calculation Cost
Cache reads 45,000 x $0.50 / 1,000,000 $0.02
Fresh input 5,000 x $5 / 1,000,000 $0.03
Output 8,000 x $25 / 1,000,000 $0.20
Per session $0.25

Ten sessions is $2.50 a day, and 21 working days is about $52 a month.

The same workload on Claude Sonnet 4.6 ($3 input, $15 output, $0.30 cache read):

Line item Calculation Cost
Cache reads 45,000 x $0.30 / 1,000,000 $0.01
Fresh input 5,000 x $3 / 1,000,000 $0.02
Output 8,000 x $15 / 1,000,000 $0.12
Per session $0.15

Ten sessions is $1.50 a day, and 21 working days is about $31 a month. The same workload, about 60% of the cost on a mid-tier model, with no change to the token counts.

These are estimates, not quotes. The real driver of variance is output tokens. Push a session to 20,000 output tokens instead of 8,000 and the Opus total roughly doubles, because output bills at $25 per million. Output volume is where a comfortable estimate becomes a painful line item.

Scale the estimate to a team

The arithmetic multiplies disappointingly fast, and that is worth saying before you plan a rollout. Claude Code's own cost documentation reports that across enterprise deployments the average cost runs about $13 per developer per active day, or $150 to $250 per developer per month, with 90% of users staying below $30 per active day.

Work the multiplication yourself. Ten developers at the Opus workload above is roughly $520 a month before any rate change. Fifty developers is $2,600. Those figures assume nobody runs parallel agent instances, nobody leaves long sessions open, and nobody lets responses run long, which is why real team bills so often exceed the per-developer math.

The same documentation recommends starting with a small pilot group and using the tracking tools to establish a baseline before a wider rollout. Measure a handful of real developers, apply the formula to their token counts, and you get a number grounded in your own usage rather than a guess.

A copy-ready calculator you can build

The quickest tool is a spreadsheet with four columns per model: input tokens, cached tokens, output tokens, and the unit prices. The formula fits in one cell:

= (input_tokens / 1000000 * input_price)
+ (cached_tokens / 1000000 * cache_price)
+ (output_tokens / 1000000 * output_price)

Fill in the unit prices from the rate table at the top. Pull the token counts three ways: from /usage for your own sessions, from the Claude Console Usage page for API billing, or from the rule-of-thumb estimate of 0.75 words per token for workloads you have not measured yet.

Build a second row that applies prompt caching to the whole context, using the cache read price instead of the input price for the stable portion. The gap between the two rows is the number you are leaving on the table when caching misses. Keep the stable content, the system prompt, the framework docs, and the conversation history, at the front of the prompt where the cache can serve it, and that gap narrows.

For live rates, do not trust any secondary page, including this one, the moment you commit real money. Open Anthropic's official pricing page and the interactive calculators such as llm-prices.com to confirm the current numbers, because introductory rates expire and tiers shift.

The biggest lever: model choice and routing

Every source agrees on where the savings live, and none of them point at the subscription. Anthropic's own guidance is to choose Haiku for the lightest work, Sonnet for most production workloads, and Opus for the hardest reasoning. CostGoat turns that into a fallback chain: route classification, extraction, and routine chat to Haiku first, escalate to Sonnet for general coding, and reserve Opus for complex agentic or long-context work.

The spread makes the point numerically. At the current introductory rate for Sonnet 5, input runs $2 per million against Opus 5 at $5, and output runs $10 against $25. Haiku sits at $1 and $5. The same task on the top tier costs multiple times more than on the entry tier, and for most requests nothing about the answer needs the top tier.

Do not read that as permission to run everything on Haiku. The reasoning quality cliff is real, and a wrong answer that has to be regenerated costs more than the model you saved on. The lever is not "one model for everything." It is assigning each request the least expensive model that can complete it, which is what the Anthropic guidance and the CostGoat fallback chain both describe.

At team scale, hand-switching models per request stops working. That is when model routing becomes an infrastructure decision rather than a habit. A model router or an LLM gateway sits between your traffic and the providers, decides per request which model to send, and tracks spend per key. Claude Code's own documentation describes exactly this: an LLM gateway that routes Claude Code traffic through a proxy and records spend per API key. The same concept, applied to model selection, is the automation of the model-choice lever. Prompt caching and model routing explains how to stack those two savings without losing your cache hits.

Five concrete ways to cut the bill

These five levers come from the sources above or from neutral, well-established usage patterns, and they work on both the API and subscription billing. Order them by impact; the first two are usually the largest by far.

1. Match the model to the task. Route routine work to a less expensive model and reserve the frontier tiers for hard reasoning. Anthropic recommends Haiku for the lightest tasks, Sonnet for most production workloads, and Opus for the most complex reasoning. Inside Claude Code, switch with /model mid-session or set a default in /config, and pin subagents to Haiku where the work allows. The tier spread is roughly 5x on input and output, so this single habit outranks every other lever on this list.

2. Make prompt caching work. The API re-reads your conversation and context on every request. With caching active, that repeated context reads at 10% of standard input. Anthropic prices the 5-minute cache write at 1.25x and the 1-hour write at 2x, with reads at 0.1x either way, so caching pays after one read for the short lifetime and after two for the long one. Claude Code enables prompt caching automatically for repeated content such as system prompts. Keep stable context at the front of the prompt and watch the cache read count in /usage. A silent cache miss re-bills that content at full input price, roughly ten times the cached rate, and nothing flags it by default. The full mechanics are covered in prompt caching and model routing.

3. Batch whatever can wait. Anthropic's Batch API processes asynchronous workloads within a day at a 50% discount on both input and output. Nightly code analysis, bulk refactors, documentation generation, and data extraction are the natural candidates. On Opus 5 the batch input drops to $2.50 per million and batch output to $12.50, so anything you can push into the queue halves the token cost of that work. Interactive sessions cannot batch; the discount is reserved for work with a time window.

4. Cap output and thinking. Output bills at five times input, and thinking tokens bill at the output rate. The fastest way to inflate a bill is to let responses run on without a length target. Instruct brevity, set response limits, and, in Claude Code, lower the effort level for tasks that do not need deep reasoning and reduce the extended-thinking budget where the model permits it. An agent that streams an essay where a one-paragraph answer would do is buying the most expensive tokens you sell. Treat every unconstrained completion as a leak.

5. Keep context small and control parallel work. Every request carries your full conversation, so a session that has been open all day re-sends the whole history on each turn, even for a one-line question. /clear between unrelated tasks stops that bleed at zero cost. Keep CLAUDE.md lean, under about 200 lines, by moving specialized workflow instructions into skills that load on demand, and disable MCP servers you do not use. Each active agent teammate keeps consuming tokens until it exits, and Claude Code's documentation puts agent-team usage at roughly 7x a standard session because every teammate holds its own context window, so keep teams small and shut them down when the work is done. Delegate verbose operations, test runs and log scans, to subagents so the noisy output stays out of your main context.

The routing decision at scale

The five levers are all tractable by hand for one developer. The scale problem is different. A solo engineer can flip /model when a task changes. An organization running thousands of agentic calls a day cannot task every developer with remembering to route, batch, and cap.

That is the argument for automating the decision. A gateway or model router sits between the application and the providers and applies the model-choice rule per request, so the fallback chain that CostGoat describes and that Anthropic's guidance implies becomes enforced policy instead of individual discipline. The same layer gives you the spend-per-key visibility that per-dollar cost attribution needs, which is how those first four levers stop being advice and become measurements. For a broader playbook that ties all of this together, the LLM cost optimization strategies guide walks through the full set of tactics in one place.

Subscription versus API: a note

This post estimates token cost, which is the common denominator for every way you run Claude Code. Whether the arithmetic lands on a flat subscription or a per-token API bill is a separate decision, and it swings on volume: the flat plans effectively discount heavy interactive use, while the API wins for light or spiky load and for any workload that needs per-request cost attribution. The break-even math and the current plan prices, including Pro at $20 a month and the Max tiers, live in the full Claude Code cost breakdown. Run the token estimate here, then take that number over to decide which billing path fits.

Frequently asked questions

How do I calculate Claude Code cost? Multiply your input, cached, and output token counts by their per-million-token prices and add the results. Use /usage inside Claude Code for real counts, or estimate at 0.75 words per token, and pull current rates from Anthropic's pricing page.

Why is output so much more expensive than input? Every current Claude model charges five times as much for output as for input, and thinking tokens bill at the output rate. Constraining output length is the direct way to cap the most expensive tokens in a session.

How much does Claude Code cost per month? It depends on usage. CostGoat brackets estimate personal projects at $10 to $50 a month, small apps at $50 to $200, production apps at $200 to $1,000, and enterprise at $1,000 and up. Anthropic reports enterprise averages of about $13 per developer per active day, with 90% of users under $30 per day.

Is there a free tier? New API users get $5 in free credits at signup, according to CostGoat, enough to test at current rates. Beyond that the API is pay-per-token, and Claude Code itself needs a paid subscription plan (Pro, Max, Team, or Enterprise) or an API account.

How do I know if caching is failing? Check the cache read and cache write counts in /usage. A cache miss re-bills the full context at standard input price, roughly ten times the cached rate. /usage also flags cache misses and long context directly when either accounts for 10% or more of recent usage.

The takeaway

Estimating Claude Code cost is a three-line arithmetic problem once you have token counts and rates, and this post gives you the formula, two labeled worked examples, and the source to confirm live prices. The number will keep moving because output dominates, caching cuts repeated input to a tenth, and prices shift when introductory rates expire.

The five levers, model choice first and foremost, then caching, batching, output control, and context discipline, are where a predictable bill comes from. None of them require a new product. They require attention, and at team scale they require automation. Measure with /usage, batch what can wait, keep the context small, and route each task to the model that fits it. Do that and the estimate you build today stays close to the bill you pay next month.

Cut LLM spend without cutting quality

Route, cache, and govern AI traffic from one OpenAI-compatible platform.

Start Free → See Features