Token
Definition
The unit of text a model reads and writes, often a word or part of a word; in English a token averages about four characters of text.
In more detail
Pricing, context limits and output limits are all counted in tokens. Code, non-English text and unusual strings often use more tokens per character than plain English prose.
Tokenizers differ between model families, so the same text can be a different number of tokens on different models, and a price per million tokens is only comparable once you know the counts. Most providers offer a token-counting endpoint or library. In practice, count tokens on a sample of real inputs before you estimate cost or decide how much retrieved context fits, and remember that reasoning models also bill for the thinking tokens you never see.
Related terms
Context window
The maximum number of tokens a model can consider in one request, covering both the input you send and the output it writes.
Max tokens
A request setting that caps how many tokens a model may generate in its reply; the model can stop earlier but never goes past the cap.
Tokenizer
The algorithm and vocabulary that split text into tokens and map each one to the number a model processes. Each model family has its own.
Constrained decoding
Masking out disallowed tokens during generation so a language model can only emit text matching a schema or grammar.
Large language model (LLM)
A neural network trained on very large amounts of text to predict the next token, which lets it generate and transform language.
Log probabilities (logprobs)
The log of the probability a model gave each token it generated, returned by some APIs to show how confident the model was.
Read more about Token
- How large language models work, without the maths
A large language model predicts the next token, one at a time. Tokens, training, context windows and why that design explains the limits you hit at work.
- AI literacy
Knowing what current AI systems can and cannot do, and how to check their output.
- Tokenizer
The algorithm and vocabulary that split text into tokens and map each one to the number a model processes. Each model family has its own.
- LLM cost optimisation
Cutting LLM costs with caching, model routing, batching and budgets.