What counts as a token?

A token is the unit a language model actually reads, writes and bills for — and it is not a word, not a character and not a syllable. Before a model ever sees your text, a program called a tokenizer cuts it into pieces drawn from a fixed vocabulary that was learned from training data: common words survive whole, rare words are split into fragments, and punctuation, spaces and digits all consume pieces of their own. The number on your bill is the length of that piece list, which is why the same paragraph can cost noticeably different amounts on two different models. This article explains how the cutting works, why some kinds of text are token-expensive, and how to count properly before you send — the LLM Usage Analyzer shows the counts a provider actually charged once the calls are made.

The model never sees your words

A language model does not read text. It reads a sequence of integers, each one the index of a piece in its tokenizer’s vocabulary, and it writes its answer by predicting further integers from the same list. Everything you send — system prompt, conversation history, pasted documents — is converted to that integer sequence first, and everything the model returns is converted back. The vocabulary is finite and fixed for a given model, typically tens of thousands to a few hundred thousand entries, and the pieces in it range from a single byte up to whole frequent words and common multi-word fragments.

The pieces are subwords, and that choice is deliberate. A character-level vocabulary would be tiny and could represent anything, but sequences would be several times longer and the model would have to learn spelling before it could learn meaning. A word-level vocabulary would keep sequences short, but it would explode in size, and every name, typo, URL or newly coined term would fall outside it entirely. Subwords split the difference: text the tokenizer has never seen still encodes, just inefficiently, as a run of smaller fragments — a long uncommon word may arrive as a stem, a suffix and a spare syllable, while an everyday word with its leading space is a single piece.

Byte-pair encoding, the algorithm behind most current tokenizers, produces exactly this behaviour. The practical consequence is that token count is not a property of your text alone. It is a property of your text as cut by one specific vocabulary — and that is the fact every estimate, budget and context-window calculation has to respect.

How the pieces are learned: byte-pair encoding

Training a BPE tokenizer starts from the smallest possible pieces: the 256 byte values. The trainer then scans a large corpus of text, counts which adjacent pair of pieces occurs most often, and merges that pair into a new, longer piece — th plus e becomes the, and so on, tens of thousands of times. Each merge is recorded in order. The finished vocabulary is therefore a fossil record of what was frequent in the training corpus: the most common words, word fragments, punctuation patterns and whitespace runs in that data each earned their own token.

Encoding runs the learned merges in the same order, so frequent strings collapse into few tokens and rare strings stay fragmented. A few consequences surprise people the first time they look at a tokenized text. The space before a word usually belongs to the word’s token, so a word mid-sentence and the same word at the start of a line can count differently. Capitalisation changes the pieces — OpenAI’s documentation uses red, Red and red as the example of three inputs one encoding can represent three ways. Numbers are typically split into short digit groups rather than stored whole, and runs of newlines or indentation are tokens in their own right, not free formatting.

Every tokenizer counts differently

Because the vocabulary is learned from a corpus, and every provider trains on a different corpus with a different target vocabulary size, no two model families cut text identically. OpenAI has shipped successive encodings whose counts differ on the same passage; Anthropic’s token-counting documentation warns that the tokenizer introduced with its newer Claude generations counts the same prompt roughly 30 percent higher than the tokenizer in its earlier models, with the exact increase depending on the content. Neither figure is an error. The counts are answers to different questions: how many pieces does this vocabulary need for this text?

The fallout is practical. A prompt that fit a context window on one model may not fit on another. A cost estimate carried over from a previous model silently understates or overstates the new one. A token count quoted in a blog post, a screenshot or a colleague’s spreadsheet is not transferable to your model at all. When you migrate models, the honest procedure is to recount a representative sample of your real prompts with the new tokenizer before believing any budget — a chore that takes minutes and routinely moves the projected bill by double-digit percentages.

Why Chinese and code are token-expensive

The famous rule of thumb — one token is roughly four characters, or about three-quarters of a word — is a statement about English prose in tokenizers trained mostly on English. Their vocabularies are dense with merged English chunks, so English rides cheap. Text the training corpus saw less of pays more. A Chinese character commonly costs around a token, and characters the vocabulary covers poorly fall back toward byte-level pieces, so a passage of Chinese typically carries far fewer characters per token than the same passage in English — often closer to one character per token than four. Japanese and Korean behave similarly, and emoji, being multi-byte and rare in training data, are expensive out of proportion to their size.

Code has the same problem for different reasons. Indentation is literal space tokens, repeated at every line. Operators and brackets are cheap because they are frequent, but identifiers are rare words and get fragmented — a long camelCase or snake_case name is cut at its seams and then some. Worst of all are strings with no learnable pattern: hashes, UUIDs, access keys, base64 blobs and long URLs have almost no frequent pairs to merge, so they encode at close to a token per few characters, sometimes worse. A prompt that pastes a log file, a minified script or a table of IDs can cost several times what its character count suggests, and the four-characters rule will not warn you.

Count with the target model’s tokenizer, before you send

Counting correctly means counting with the tokenizer of the model you will actually call, on the request you will actually send. The providers ship the tools: OpenAI’s open-source tiktoken library selects the right encoding per model, and Anthropic’s count_tokens endpoint accepts the same structured message you are about to send and returns its input count without generating anything. Count the assembled request, not just the user’s visible text: the system prompt is resent and rebilled on every call, message scaffolding and tool definitions add tokens of their own, and OpenAI explicitly notes that a plain-text count does not include those structural pieces.

Then close the loop against reality. Every API response reports the usage it actually charged, and exported usage records aggregate it — which is where the LLM Usage Analyzer and the companion analysis of where LLM bills actually go come in. Compare your pre-send estimates with the billed counts per feature and per model; where they drift, fix the estimate, because a small per-request error compounds across millions of calls into a budget that was never real. Estimate with the tokenizer, verify with the usage, and re-baseline both whenever you change models.

Sources and further reading

Frequently asked questions

How many words is a token, roughly?

For English prose, OpenAI’s published rule of thumb is that one token is approximately four characters, or about three-quarters of a word — so 100 tokens is roughly 75 words. Treat it as a first guess for English only. The same documentation stresses these are estimates, not exact counts, and that other languages have different relationships between characters, words and tokens; CJK text and code diverge from the rule far enough to break budgets built on it.

My per-token price stayed the same, but the same prompts cost more after I switched models. Why?

Because price per token is only half the product. The new model’s tokenizer may cut your text into more tokens — Anthropic documents roughly 30 percent higher counts for the same prompt on its newer tokenizer — and the model may also generate longer output. Recount your prompts with the new model’s tokenizer, then compare total tokens at the new rate; the LLM cost calculator is built for exactly that comparison.

Does the system prompt count toward the bill?

Yes. Everything in the request counts: the system prompt, the full conversation history you resend each turn, tool definitions and the message structure itself — not just the user’s latest text. That is why provider counting endpoints accept the whole assembled message rather than a plain string, and why long system prompts and large tool catalogues are a fixed tax on every single call.