Wetin Be Claude Tokens? Claude Code Token Math
Claude token na small characters. See why one Claude Code turn fit bill 80,000 tokens, and how five idle minutes fit make your next API turn cost 5x.
Wetin be tokens for Claude?
Token na the unit of text wey Claude dey read and write: small part of word. Anthropic own glossary talk say e dey around 3.5 English characters for models before Claude Opus 4.7. For the current tokenizer, e dey closer to 2.5, because Anthropic size 1M tokens as about 2.5M characters there. Anyhow, once you count spaces and punctuation, e mean say words dey use well over one token each. So 1,000 words of prose fit pass 1,300 tokens without problem. Code dey use more tokens for each line: braces, operators, underscores, and indentation dey split into more tokens per character than English. Source file wey get some hundred lines commonly fit weigh several thousand tokens. If agent decide to read 2,000-line file, na five-figure token cost be that before anybody write one new code line.
Two things about tokenizers dey confuse people. First, each model get its own tokenizer. As of October 2026, Claude Opus 4.7 and every later model, including the current Fable 5.1, Opus 5.5, Sonnet 5.5, and Haiku 5.5, dey use newer tokenizer wey dey produce roughly 30% more tokens for the same text than earlier Claude models like Haiku 4.5. The exact increase depend on the content. This change affect anything wey you budget with tokens, even though per-token prices no increase together with am. Second, tiktoken, the library wey every blog post dey use, na OpenAI tokenizer, e no be Claude own. So its counts no go match wetin Anthropic dey bill. The only count wey you fit trust na the count_tokens endpoint, wey we cover below.
Wetin make your coding session cost wetin e cost
Every Claude bill, whether na API invoice or subscription limit, dey run mainly on one meter: tokens wey enter and tokens wey comot. Some API tools add their own charge line (web search, for example, cost $10 for every 1,000 searches as of October 2026, on top of the tokens wey the results add), but for coding session na token meter dey move. Pricing page make am look simple: some dollars for every million input tokens, and some dollars for every million output tokens. But e no tell you say for agentic coding session, input side of the meter dey run much hotter than intuition suggest, because the whole conversation dey send again for every single turn. I don sell metered infrastructure for fifteen years, and tokens na the first meter wey I don see where most customers genuinely no fit talk wetin dey make am spin. Na this be the meter-reading lesson: wetin count as input and output for agentic session, why resend loop dey cost so much, how prompt caching dey change the arithmetic, and which levers really dey move the number.
Wetin dey count as input: wetin meter really dey measure
People dey think say na code wey Claude write dem dey pay for. For agentic session, na small part of the bill be that. Input tokens get cheaper rate, but their volume dey much higher. Dem include:
- The system prompt. Claude Code own harness instructions, plus your
CLAUDE.mdand memory files, load when session start and dey present for every request after that. - Tool definitions. Every tool schema wey the agent fit call. Every MCP server wey you connect adds to this fixed overhead. But Claude Code now dey defer full MCP tool definitions by default. So only tool names dey inside context until you first use one. This reduce the cost, but e no remove am.
- Every file wey the agent read. One
Readof source file puts the whole file inside context, and e remain there. - Every tool result. Test runs, grep output, terminal output, build logs — all of dem come back as input tokens. Test suite wey fail and print 8,000 lines be like small book. As of October 2026, Claude Code dey pass around 30,000 characters of command output inline by default. Anything wey pass this length go come as saved file plus preview of up to 2,000 characters. But every output under this limit, and every later read of the saved file, still dey bill in full.
- The whole conversation so far, re-sent on every turn. This one deserve im own section.
The resend wey nobody dey price
Claude API no dey keep state. E no remember your session between requests; nothing dey remember am. So for turn 2, client go send turn 1 plus the response plus your new message. For turn 50, e go resend anything wey still dey inside context from turns 1 through 49, every file wey e read, tool result, and diff wey compaction never remove, plus turn 50. (Compaction dey replace old history with summary, while file reads from subagent dey remain for the subagent own context; na only the result dey come back.) Model go read the whole transcript wey remain every time, and dem dey bill every token wey e reread as input.
The result be say cost for each turn dey grow roughly linearly with session length, while total session cost dey grow roughly quadratically. Message wey cost half a cent for turn 3 fit cost twenty times that amount for turn 60, even for the same one-line question, because e dey carry sixty turns of extra content. Na this single fact explain most “why my bill high like this” tickets, and no be Claude quirk. Every LLM product wey look like e dey keep state na stateless API underneath, with resend loop dey run behind am.
Output: wetin you see, plus the thinking wey you no see
Output tokens cost pass input tokens five times for the current lineup ($10/$50 for Fable 5.1, $4/$20 for Opus 5.5, $2/$10 for Sonnet 5.5, $0.10/$0.50 for Haiku 5.5 for prompts wey no pass 100,000 tokens, as of October 2026). Output include the text and code wey Claude generate, plus thinking tokens: the internal reasoning wey the model do before e answer. Two facts matter here. Thinking dey billed with output rates and e count against max_tokens, an API response wey die with stop_reason: "max_tokens" and truncated answer often mean say thinking don use the budget before the answer fit come out. And for current models, the reasoning summary fit no display at all. API omit am by default for Fable 5.1, Opus 5.5, Sonnet 5.5, Haiku 5.5, and earlier models back to Opus 4.7, but the thinking still happen and dem still bill am. Wetin no dey visible no mean say e free.
Claude Code enable extended thinking by default because e dey improve multi-step work in measurable way, and the default budget fit reach tens of thousands of tokens for one request. For simpler tasks, you fit reduce am: lower the effort level with /effort or for /model, or turn thinking off for /config on models wey allow am. As of October 2026, Claude Code no fit turn thinking off for Opus 5.5, Sonnet 5.5, Haiku 5.5, or the Fable models, so effort na the control wey remain there. The API give you more space for two of dem. Haiku 5.5 accept thinking: {"type": "disabled"} for high effort or below, and the older Opus 5 do the same, while the older Sonnet 5 accept am for every effort level, including xhigh and max. Sonnet 5.5 reject "disabled" and use thinking: {"type": "between_tools"} instead. This reduce up-front thinking for low, medium, or high effort, so request wey no use tools fit get answer without thinking first. Only Opus 5.5 and the Fable models keep thinking for anything wey you send. This na real cost control, no be superstition.
Prompt caching dey change the calculation
Prompt caching na why resend loop no dey bankrupt everybody. API fit cache stable prefix of your prompt, system prompt, tool definitions, and conversation history. For the next request, e fit serve am for small part of the price. As of October 2026, the multipliers be: cache write dey cost 1.25× of the base input rate (2× for the 1-hour variant), while cache read dey cost 0.1× for most models, 0.05× for Claude Opus 5.5 and Claude Sonnet 5.5, and 0.025× for Claude Fable 5.1. Writes dey cost extra; reads na 90% discount for most models, 95% for Opus 5.5 and Sonnet 5.5, and 97.5% for Fable 5.1. (Sonnet 5.5 read rate drop from 0.1× to 0.05× on October 7, 2026.) Just one read don already recover the extra cost of the 5-minute write.
Claude Code dey manage caching for you. For healthy session, almost all that big resend dey come from cache. But cache dey expire after some time wey you no use am. As of October 2026, Claude Code dey give your main conversation one-hour cache on subscription inside the usage wey your plan include. For API key, cloud provider, or when you dey use usage credits, cache dey last five minutes from the last use (the promptCacheTtl setting fit request the one-hour option there, with 2× write rate). For five-minute cache, if you leave for coffee wey take long, come back, and send message, cache don expire. The complete accumulated prefix go write again at 1.25× instead of reading am at cache rate. For 150K-token session, one cold turn go write all 150K tokens at 1.25×. Warm turn for the same prefix for read am at 0.1×. That na 12.5-fold difference for the prefix (25-fold for Opus 5.5 and Sonnet 5.5, 50-fold for Fable 5.1). This na the result wey dey surprise people but important to understand: if you idle before you continue, e fit cost more than continuous work, because every idle gap wey pass TTL go change your next turn from cheap read to expensive re-write. Work in stints. For five-minute cache, no drip-feed one huge session with one message every ten minutes.
If you dey call API from your own application for VPS, none of this go happen automatically. You need opt in with cache_control. The common mistake na to interpolate timestamp or request ID inside system prompt. That one dey change the prefix bytes for every request and silently disable caching. The sign na usage.cache_read_input_tokens wey remain zero across calls wey look identical.
Formula, with one worked example
Ignore anybody wey dey quote one flat “session dey cost $X.” Sessions fit differ by two orders of magnitude. Na this formula dey hold:
turn cost = (uncached input x base input price)
+ (cache writes x 1.25 x base input price)
+ (cache reads x read multiplier x base input price)
+ (output incl. thinking x output price)
read multiplier = 0.10 on most models, 0.05 on Opus 5.5 and Sonnet 5.5, 0.025 on Fable 5.1
session cost = sum over all turnsWorked example for Claude Opus 4.8, wey don become legacy model but still dey available and, as of October 2026, still cost $5 per million input tokens and $25 per million output. One mid-session turn carry 80,000 tokens of accumulated context: 75,000 read from cache, 3,000 newly written, 2,000 uncached fresh input, and 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
About $0.10 for the turn; fifty turns like this one go reach around $5. Now, if cache don expire before the same turn: the 78,000 cacheable tokens go write again at $6.25/M, plus the same 2,000 uncached tokens at $5/M. Together, dem go cost about $0.50 before output, roughly five times the complete warm turn, even though na the same work. Na this gap explain the whole caching matter with one number. For the current Claude Opus 5.5 ($4/$20, with cache reads at 0.05×), the same warm turn go cost about $0.07 (reads $0.015, writes $0.015, uncached input $0.008, output $0.030). The cold version go cost $0.40 before output, closer to six times the warm turn. Those same four lines na the only honest way to compare vendors, because sticker rates no include cache reads and thinking at all. Running dem over three real jobs show where the Claude bill dey above or below the OpenAI one.
If na the billing unit itself you wan understand, instead of just one turn, see wetin one million tokens work out to for pages, files, and dollars dey run the same calculation one level higher. Use this for calibration, not prediction: Anthropic published figures for enterprise Claude Code deployments, as of October 2026, show average of about $13 per developer per active day and $150 to $250 per month, while 90% of users dey stay under $30 per day. Your own result depend on model choice, session hygiene, and codebase size. Na exactly why the levers below matter.
Seeing your own usage
For Claude Code, the command na /usage (/cost still dey work, na alias). The Session block for the top show token statistics and locally computed cost estimate for the current session. For subscription plans, the same screen show your plan-limit bars and breakdown wey attribute recent usage to skills, subagents, plugins, and individual MCP servers. For recent versions, the Session block also get Prompt cache (main) line wey show the share of input wey cache serve, the misses, and whether the cache warm now. For authoritative billing on API accounts, the usage page for Claude Console na the source of truth; the CLI figure na estimate. /context draw colored grid of wetin dey occupy the context window, system prompt, tools, MCP definitions, files, history, and e na the fastest way to find bloated CLAUDE.md or chatty MCP server. For fullscreen mode, e collapse the per-item breakdown, and passing all expand am.
From the API, every response tell you exactly wetin happen:
response = client.messages.create(model="claude-sonnet-5-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 the uncached remainder. The real prompt size na the total of all three input fields. Agent wey run for one hour and show input_tokens: 4000 no cheap; the other 200,000 tokens come from cache. To estimate before you send am, use the token-counting endpoint. E free to call, e get separate rate limit, and e count with the tokenizer for whichever model you name. Treat the result as close estimate, because billing reflect the real request:
count = client.messages.count_tokens(model="claude-sonnet-5-5",
messages=[{"role": "user", "content": big_file}])
print(count.input_tokens)Never tiktoken, because of the reason above.
Subscription plans versus pay-as-you-go
The mechanics wey dis guide use dey the same everywhere; na only the billing dey different. If you use API key, Anthropic dey bill you pay-as-you-go, per token, according to the published rates, so every number above na real money. That meter dey start earlier than many people expect, because no free tier dey available as fallback. You only get small credit when you sign up and some endpoints wey no dey charge anything. Na wetin new API account really dey get before you add card be this. Since October 7, 2026, Max or Team subscription na the exception: those plans now include monthly API credits for your own apps and agents on the Claude Platform. Max 5x get $100 per month, Max 20x get $200 per month, while Team get $20 per Standard seat and $100 per Premium seat, pooled and capped at $500. You claim the credits by linking a Console organization. Any credit wey you no use go expire when the billing cycle end, and dem no cover interactive Claude Code.
For Claude subscription (Pro, Max, Team, and legacy seat-based Enterprise plans), Claude Code usage dey use the allowance wey your plan include instead. As of October 2026, na rolling five-hour session window plus weekly window dey apply. Dem dey shared across models and claude.ai chat, and the /usage dollar figure na only information, no be bill. As of October 2026, two exceptions dey: current usage-based Enterprise seats no include any usage, so every token dey billed with standard API rates. Fable models no dey inside the allowance for Pro, standard Team seats, or standard legacy Enterprise seats; for those plans, dem dey use pay-as-you-go usage credits.
If you exhaust one window, you go see "You've hit your session limit" or "You've hit your weekly limit" together with reset time. Changing models with /model no go restore access, because all models dey share the windows. Those windows follow the account, no be the client wey you happen to dey use. This one matter if you still dey work out which things dey run natively for Linux and which plan cover each surface. The window wey you exhaust decides how long you go wait and wetin make sense to do meanwhile, so e good make you know your options when you hit limit during task. Plans fit optionally enable usage credits, wey you manage with /usage-credits, to buy usage after you reach the ceiling.
I no go print the plan quotas deliberately. Dem na the numbers wey dey change pass for this whole topic, so check claude.com/pricing and your own /usage bars instead. Token mechanics still matter for subscription. Wasteful session go use your window the same way e for use dollars. For the subscription side, see which Claude plan fit your usage.
Levers wey really dey work
- Set scope for wetin the agent go read. “Fix the validation bug for
auth.py” dey read one file; “improve this codebase” dey read forty. KeepCLAUDE.mdlean because e dey load for every session. Put only the important things there, then move workflow-specific instructions go skills wey load when dem need am. - Make am clear and compact.
/clearbetween unrelated tasks, otherwise stale context go dey send again and dem go bill you for am on every later message. For one long task,/compact Focus on the failing tests and the diffdey summarize the history and keep you away from quadratic cost curve. - Use model wey match the work. Sonnet fit handle most coding for $2/$10 per million tokens as of October 2026. That price don become standard, no be introductory price again: Sonnet 5.5 na $2/$10, and Sonnet 5 remain $2/$10 after dem cancel the planned September 1 increase to $3/$15. Compare am with Opus 5.5 for $4/$20. Haiku 5.5 na $0.10/$0.50 for prompts up to 100,000 tokens, and $0.50/$2.50 above that; e fit handle mechanical subagent work like log triage well. Fable 5.1 dey the other end for $10/$50. Na the same rate as Fable 5, and e cost two and a half times Opus 5.5 for both sides of the meter. So, know which jobs really deserve that rate before you leave am selected for routine work.
/modelfit switch model during session. - Pre-filter verbose output. Hook wey use
grepreduce test run output to only failures before Claude see am fit turn 20,000 tokens of tool result to 300. E go do this again every time dem resend that turn in future. - Batch wetin no need interaction. For your own API pipelines, classification, bulk review, and nightly jobs, Batches API dey run the same models with 50% discount in exchange for asynchronous delivery.
- Respect cache clock. Work in continuous stints. Detached Claude Code session for tmux on VPS no dey cost anything while e idle. Tokens only dey spend when turn run. But if idle time pass cache TTL, warm cache go expire, and next turn go pay to rewrite the context.
FAQ
How many tokens does a coding session in Claude Code use?
Fixed number no dey. One mid-session turn fit commonly carry tens of thousands of prompt tokens after files and history don pile up, and one working session fit reach millions. Most of dem dey come from cache for one-tenth of the base rate or less, depending on the model. For calibration, Anthropic published enterprise figures as of October 2026 show average of around $13 per developer per active day, with 90% of users below $30. Run /usage for your own session; watching am for five minutes better pass any published average.
Do thinking tokens cost money even when I can't see them?
Yes. Thinking tokens dey billed as output tokens, for the expensive rate, and dem count against max_tokens. Current models still bill dem even when the interface no show the reasoning summary. If response cut off with stop_reason: "max_tokens" before the visible answer finish, thinking tokens likely don use the budget. For Claude Code, reduce the effort level with /effort for tasks wey no need deep reasoning.
Why does a long Claude Code session get more expensive per message?
Na because API dey stateless: every turn dey send the conversation wey still dey inside context again, including every file read, tool result, and previous exchange wey compaction never remove, as billed input. So turn 50 carry turns 1 through 49 as input. Prompt caching serves the repeated prefix at one-tenth of the base input price for most models (5% for Opus 5.5 and Sonnet 5.5, 2.5% for Fable 5.1), but the prefix itself dey continue to grow. Any idle gap wey pass the cache TTL turns the next turn into full-price rewrite. /compact dey reduce the history; /clear dey reset am.
How do I 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 authoritative API billing information, 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 real prompt size. To estimate ahead of time, use the count_tokens endpoint, never tiktoken.