
Tokens are the unit of currency in every LLM interaction. Understand how text becomes tokens, why the count never matches your word count, and which levers actually control cost at scale.
A deep read: the full picture, with the receipts.
Tokens are the atomic unit every large language model uses to read your input and generate its output. If you use any LLM API (OpenAI, Anthropic, Google, Meta's Llama, DeepSeek, Mistral, or otherwise), you are billed in tokens, and the way those tokens are counted is not the same as counting words or characters.
Understanding this isn't an academic exercise. It changes how you write prompts, how you architect systems, and how much your application costs at scale.
What a Token Actually Is#
A token is a chunk of text produced by a process called tokenization: splitting raw text into pieces that the model can map to a numerical ID. Tokenizers don't split on word boundaries the way a human would. They use algorithms (Byte Pair Encoding and its variants are the most common) that learn frequent character sequences from a large training corpus and merge them into single tokens. The more often a sequence appears in training, the more likely it earns its own token.
In practice this means:
A rough heuristic that holds across most English-language models: one token ≈ four characters ≈ 0.75 words.
But it is only a heuristic. Paste code, an account number, or a paragraph in Korean, and the ratio shifts, sometimes sharply.
The Tokenization Pipeline, Step by Step#
When you submit a prompt, the following happens before any computation on meaning occurs:
This is why models can stumble on character-level tasks ("how many r's in 'strawberry'?"). They don't see letters; they see token IDs that represent chunks. The word may arrive as a single token or two, with the individual letters never exposed to the model at all.
Context Windows and Why Token Limits Bite#
Every model has a context window: the maximum number of tokens it can hold in a single interaction, covering both the input you send and the output it generates. If you exceed the window, the request is rejected, or older content is truncated, depending on the implementation.
Context windows have expanded dramatically, from a few thousand tokens in early GPT-3 variants to a million tokens or more in several current frontier models, with a handful of open-weight models advertising multi-million-token windows. But a bigger number on the spec sheet doesn't solve everything:
The architecture implication: for production systems, retrieval-augmented generation (RAG) exists precisely to avoid stuffing entire knowledge bases into the context. Retrieve only the relevant chunks, keep the context lean, and you win on cost, latency, and answer quality at once.
How You're Actually Billed#
API providers bill separately on input tokens and output tokens, and output tokens typically cost several times more than input tokens. The reason: generating tokens (autoregressive decoding, one token at a time) is computationally heavier than encoding the prompt in a single forward pass.
Key billing mechanics to understand:
Practical Token Arithmetic for Builders#
A few concrete implications for anyone building on top of an LLM API:
Why Non-English Text Costs More (and What to Do About It)#
Because tokenizer training corpora skew heavily toward English, other languages are underrepresented in the vocabulary. A sentence in Turkish, Thai, or Arabic typically requires more tokens than the same meaning in English. This is not a quality problem (the model handles the language fine), but it is a cost and context-window problem: the same conversation eats more of your budget and fills the window faster.
Newer, larger-vocabulary tokenizers have narrowed this gap (GPT-4o's 200k-token vocabulary, for instance, compresses many non-Latin scripts noticeably better than its predecessor), but they have not erased it. For multilingual applications at scale:
The Meta-Point: Tokens Are a Design Constraint#
Most developers treat token limits as a nuisance to route around. A sharper view: tokens are the fundamental design constraint of LLM-based systems, the same way memory and bandwidth are constraints in systems programming. Every architectural decision in an LLM application (what goes in the context, how conversation history is managed, which model handles which request, whether reasoning mode is worth its output cost) is really a decision about tokens.
Getting fluent with tokenization doesn't require deep ML knowledge. It requires measuring, experimenting with your specific tokenizer (OpenAI, Meta, and others publish theirs as open-source libraries), and treating token counts as a first-class engineering metric alongside latency and error rate.
Key Takeaways



Discussion