Wetin be tokens for Claude and cost
One Claude token na roughly 3.5 characters. Learn why one Claude Code turn fit use 80,000 tokens and why idle minutes dey make your bill 5x higher.
Wetin be tokens for Claude?
Token na the unit of text wey Claude dey read and write: e be like small part of word, roughly 3.5 English characters. Anthropic glossary talk am so, and if you count spaces and punctuation, e go pass one token per word. So, one thousand words of prose go reach well pass 1,300 tokens. Code dey heavy pass for every line: braces, operators, underscores, and indentation dey split into more tokens per character than English. If source file get few-hundred-line, e dey weigh several thousand tokens. If agent decide to read 2,000-line file, e don consume five-figure token purchase before person even write one line of new code.
Two things about tokenizers dey confuse people. First, dem dey change for every model. As of July 2026, Opus 4.7 and later, Sonnet 5, and Fable 5 dey use new tokenizer wey dey produce roughly 30% more tokens for the same text than old Claude models (the exact increase dey change based on content). This one mean say anything wey you budget for tokens go change, even though per-token prices no increase. Second, tiktoken, the library wey every blog post dey use, na OpenAI tokenizer, and e dey undercount Claude by roughly 15–20% for ordinary text, and even more for code. The only count wey you fit trust na the count_tokens endpoint, wey we go explain below.
Why your coding session cost dey reach dis level
Every Claude bill, whether na API invoice or subscription limit, depend on one meter: tokens wey dey go in, and tokens wey dey come out. De pricing page make am look simple: so many dollars per million input tokens, and so many per million output tokens. Wetin dem no tell you na say for agentic coding session, de input side of de meter dey run faster than wetin person go expect, because dem dey resend de entire conversation every single turn. I don sell metered infrastructure for fifteen years, and tokens na de first meter wey I see wey most customers no fit really tell wetin dey make de meter spin. Dis na de lesson for meter-reading: wetin count as input and output for agentic session, why de resend loop expensive so much, why prompt caching change de math, and which levers dey actually move de number.
Everything na input: wetin de meter dey count
People dey think say na de code wey Claude write dem dey pay for. For agentic session, dat one na small part of de bill. Input tokens — de one wey cheap but de volume plenty pass — include:
- The system prompt. Claude Code harness instructions, plus your
CLAUDE.mdand memory files, wey load for session start and dey stay for every request wey follow am. - Tool definitions. Every tool schema wey agent fit call. Every MCP server wey you connect dey add to dis fixed overhead — although Claude Code now dey wait before e load full MCP tool definitions by default, so na only tool names dey context until agent first use tool, wey dey reduce but no stop de cost.
- Every file wey agent read. If you give
Readof source file, de whole thing enter context, and e go stay dere. - Every tool result. Test runs, grep output, terminal spew, build logs — all of dem dey come back as input tokens. If test suite fail and print 8,000 lines, you don pay for small book.
- De whole conversation wey dem don do so, wey dem dey re-send for every turn. Dis one deserve its own section.
Why dem dey charge plenty money
Claude API na stateless system. E no dey remember your session between requests — nothing dey stay for memory. So for turn 2, client go send turn 1, plus its response, plus your new message. For turn 50, e go re-send turn 1 go turn 49 — every file read, every tool result, every diff — plus turn 50. The model go re-read the whole transcript every single time, and every one of those re-read tokens na input wey dem dey charge.
The result: cost per turn dey increase roughly linearly as session length dey grow, and total session cost dey increase roughly quadratically. One message wey cost half a cent for turn 3 fit cost twenty times that amount for turn 60, even if na the same one-line question, because e dey carry sixty turns of freight. This na the single fact wey explain most "why was my bill so high" tickets, and e no be Claude quirk — every LLM product wey dey behave like say e get memory na stateless API wey get resend loop for underneath.
Output: wetin you see, plus di thinking wey you no see
Output tokens na dem expensive pass — dem cost five times pass input rate for current lineup ($5/$25 for Opus 4.8, $3/$15 for Sonnet 5, $1/$5 for Haiku 4.5, as of July 2026). Output include di text and code wey Claude generate, plus thinking tokens: di internal reasoning wey di model dey do before e answer. Two things matter for here. Thinking dey charge for output rates and e dey count for max_tokens — if API response die because of stop_reason: "max_tokens", e mean say thinking don chop di budget before di answer reach. And for current models, dem fit no show di reasoning summary at all — Opus 4.8, Sonnet 5, and Fable 5 no dey show am by default — but di thinking still happen and dem still go charge for am. Wetin invisible no mean say e free.
Claude Code dey enable extended thinking by default because e dey help multi-step work well well, and di default budget fit reach tens of thousands of tokens per request. For simple tasks, you fit reduce am: lower di effort level with /effort or for /model, or change di thinking settings for /config. Na real cost lever dat, no be superstition.
Prompt caching change how math work
Prompt caching na why dem no go bankrupt because of all dem resend loop. API fit cache stable prefix of your prompt — system prompt, tool definitions, conversation history — and for next request, e go serve am for much lower price. As of July 2026, dem multipliers na: cache write cost 1.25× the base input rate (2× for the 1-hour variant), and cache read cost 0.1×. Writes na premium; reads na 90% discount. One single read don pay back the 5-minute write premium well well.
Claude Code dey manage caching for you, and for healthy session, almost all dem big resend dey come from cache. But the default cache dey stay for five minutes from last use. If you go drink coffee wey take long, come back, send message — cache don expire, and the whole accumulated prefix go need re-write at 1.25× instead of read at 0.1×. For 150K-token session, that one cold turn cost more than dozen warm ones. This one na thing wey dey confuse person but e important to understand: if you dey idle then resume, e fit cost more than continuous work, because every idle gap wey pass TTL go turn your next turn from cheap read to expensive re-write. Work in stints; no dey drip-feed huge session one message every ten minutes.
If you dey call API from your own application on a VPS, you no go get any of this for free — and the classic mistake wey people dey do na to put timestamp or request ID inside system prompt, wey dey change the prefix bytes every request and dey kill caching silently. The sign be say usage.cache_read_input_tokens dey stay at zero even when calls look identical.
Di formula, with one worked example
No listen to anybody wey dey talk say "one session cost $X." Session price dey change plenty for different levels. Wetin dey true na dis formula:
turn cost = (uncached input x base input price)
+ (cache writes x 1.25 x base input price)
+ (cache reads x 0.10 x base input price)
+ (output incl. thinking x output price)
session cost = sum over all turnsWorked example for Claude Opus 4.8, wey as of July 2026 dey cost $5 per million input tokens and $25 per million output. One mid-session turn wey carry 80,000 tokens of accumulated context: 75,000 read from cache, 3,000 newly written, 2,000 uncached fresh input, 1,500 output tokens including thinking.
- Cache reads: 75,000 × $0.50/M = $0.0375
- Cache writes: 3,000 × $6.25/M = $0.019
- Uncached input: 2,000 × $5/M = $0.010
- Output: 1,500 × $25/M = $0.0375
E be like $0.10 for di turn; fifty turns wey be like dis one, e go reach around $5. Now, see di same turn after di cache expire: di full 80,000 tokens wey dem re-write at $6.25/M na $0.50 before output — e be like five times di whole warm turn, even though di work na to do di same thing. Dat gap na di whole caching story inside one number.
For calibration instead of prediction: Anthropic publish figures for enterprise Claude Code deployments, as of July 2026, dem dey average about $13 per developer per active day — $150–250 per month — wey 90% of users dey stay under $30 a day. Your cost depend on di model wey you pick, how you dey manage session, and di size of di codebase, na why di levers below dey matter.
See how you dey use am
For Claude Code, di command na /usage (/cost still dey work — na alias for am). Di Session block for top go show you token statistics and how much money you don spend for di current session based on local calculation; if you dey subscription plans, di same screen go show you your plan-limit bars and how di usage take spread for skills, subagents, plugins, and individual MCP servers. For di real billing for API accounts, di usage page for Claude Console na di real truth — di figure wey CLI show na just estimate. /context go draw colored grid for wetin dey occupy di context window — system prompt, tools, MCP definitions, files, history — and na di fastest way to see if CLAUDE.md don swell or if MCP server dey talk too much; use all if you want see di full breakdown for every item.
From di API, every response go tell you exactly wetin happen:
response = client.messages.create(model="claude-sonnet-5", max_tokens=2048,
messages=messages)
u = response.usage
total_prompt = u.input_tokens + u.cache_creation_input_tokens + u.cache_read_input_tokens
print(f"uncached={u.input_tokens} written={u.cache_creation_input_tokens} "
f"read={u.cache_read_input_tokens} output={u.output_tokens}")Note say input_tokens na only di uncached remainder — di real prompt size na di sum of all three input fields. If agent run for one hour and e show input_tokens: 4000, e no cheap; di other 200,000 tokens dem take am from cache. To estimate before you send, use di token-counting endpoint — e free to call, e get its own rate limit, and e dey count with di tokenizer of any model wey you name (treat di result as close estimate; billing na di real request):
count = client.messages.count_tokens(model="claude-sonnet-5",
messages=[{"role": "user", "content": big_file}])
print(count.input_tokens)No ever tiktoken, because of di reason wey I talk above.
Subscription plans versus pay-as-you-go
The way things work for this guide na the same everywhere; only how dem dey charge dey different. If you dey use API key, Anthropic go charge you pay-as-you-go, per token, based on the rates wey dem publish — every number wey I write above na real money. If you dey use Claude subscription (Pro, Max, Team, Enterprise), Claude Code usage go take from the allowance wey your plan give you: as of July 2026, na rolling five-hour session window plus weekly window, wey all models and claude.ai chat dey share, and the /usage dollar figure na just for information, e no be bill. If you finish one window, you go see "You've hit your session limit" or "You've hit your weekly limit" with the time wey e go reset — and if you switch models with /model, e no go give you access again, because all models dey share the same windows. You fit choose to enable usage credits, wey you fit manage with /usage-credits, to buy extra usage when you don pass the limit. I no go write the plan quotas here: dem dey change very fast, so just check claude.com/pricing and your own /usage bars instead. Token mechanics still matter even for subscription — if you waste session, e go finish your window exactly how e dey finish dollars. For subscription side, see which Claude plan fits your usage.
The levers wey dey work for real
- Limit wetin agent dey read. "Fix the validation bug in
auth.py" dey read one file; "improve this codebase" dey read forty. KeepCLAUDE.mdlean — e dey load for every session, so use only wetin dey very important — and move workflow-specific instructions go skills wey go load only when you need dem. - Make am clear and small.
/clearbetween tasks wey no get connection — stale context dey re-send, and dem go charge you again, for every next message. Inside one long task,/compact Focus on the failing tests and the diffdey summarize history down so you no go pay too much money. - Pick the right model size. Sonnet dey handle most coding at $2/$10 per million tokens for introductory pricing as of July 2026 ($3/$15 sticker, versus Opus at $5/$25), and Haiku at $1/$5 na the right tool for small subagent work like log triage.
/modeldey switch mid-session. - Filter out long output before e reach model. If you use hook wey dey grep test run down to only failures before Claude see am, e go turn 20,000 tokens of tool result to 300, and e go do am for every next time dem re-send that turn.
- Batch wetin no need for interaction. For your own API pipelines — classification, bulk review, nightly jobs — the Batches API dey run the same models at 50% off if you allow dem deliver am asynchronously.
- Respect the cache clock. Work for continuous stints. A detached Claude Code session in tmux on a VPS no dey cost anything when e dey idle — dem only dey spend tokens when turn dey run — but na the warm cache wey you go lose if you leave am idle, and the next turn go pay for the re-write.
FAQ
How many tokens Claude Code coding session dey use?
No fixed number dey — single mid-session turn fit carry tens of thousands of prompt tokens once files and history don plenty, and working session fit reach millions, but most of dem dey come from cache at a tenth of the base rate. For calibration, Anthropic publish enterprise figures as of July 2026 wey dey average around $13 per developer per active day, and 90% of users dey under $30. Run /usage for your own session; five minutes of watching am better pass any published average.
Thinking tokens dey cost money even if I no fit see dem?
Yes. Dem dey bill thinking tokens as output tokens — wey na the expensive rate — and dem dey count dem against max_tokens, and current models dey bill dem even if the interface no show the reasoning summary for display. If response cut with stop_reason: "max_tokens" before the visible answer finish, thinking likely don chop the budget. For Claude Code, lower the effort level with /effort for tasks wey no need deep reasoning.
Why Claude Code session wey long dey cost more per message?
Because the API na stateless: every turn dey re-send the entire conversation — every file read, tool result, and prior exchange — as billed input, so turn 50 dey carry turns 1 through 49 as freight. Prompt caching dey serve the repeated prefix at about a tenth of the base input price, but the prefix dey keep growing, and any idle gap past the cache TTL go turn the next turn to full-price re-write. /compact dey shrink the history; /clear dey reset am.
How I fit check my Claude token usage and cost?
For Claude Code, /usage dey show session token statistics, local cost estimate, and plan-limit bars for subscriptions (/cost na alias); /context dey show wetin dey fill the window. For correct API billing, use the usage page for Claude Console. For your own code, read response.usage — if you sum input_tokens, cache_creation_input_tokens, and cache_read_input_tokens, you go get the true prompt size — and estimate ahead of time with the count_tokens endpoint, no use tiktoken.