Token
A token is one unit in the sequence a language model processes. In text, it can represent a word, part of a word, punctuation, or whitespace.
Two words and a period become four tokens
Take the exact text “A raincoat.” With the cl100k_base encoding in OpenAI’s tiktoken, it splits like this:
The four pieces are “A”, a space followed by “rain”, “coat”, and the period. The ␣ symbol makes the original space visible. “Raincoat” spans two tokens here. Another tokenizer can split the same text differently.
What the model receives
Each piece maps to an integer in the tokenizer’s vocabulary. For this example the IDs, in order, are 32, 11422, 68512, and 13. Decoding them in order gives back the original spelling, space, and punctuation.
Why the count matters
A model’s context window is measured in tokens. Instructions, earlier messages, and text retrieved for a question can all use some of that space. The reply needs room too. When estimating whether a document will fit, use the tokenizer for the model you plan to use and account for the rest of the conversation.
For a service that charges by tokens, the same distinction matters for cost. The four tokens above count only the sample text. Sending it inside a chat request can add formatting and instructions to the total.
Follow the idea
Tokenization explains how a tokenizer chooses the boundaries.
Context window explains how many tokens can fit in one exchange.
Related concepts
Source · OpenAI’s tiktoken tokenizer
Return to Token in the A–Z glossary