Language models don't read letters or words. Before text reaches the model, a tokeniser splits it into tokens and maps each one to a number from a fixed vocabulary. The model processes that sequence of numbers and generates new ones, which are turned back into text. Common words are usually one token, rarer words split into pieces, and spaces and punctuation are part of the tokens too.
On this site "token" can also mean a card token in payments (card tokenisation) or an access token in authentication. This page is about tokens in language models.
How tokenisation works
Most current models use a variant of byte pair encoding (BPE). The tokeniser starts from bytes and repeatedly merges the pairs that occur most often in its training text, until it has a vocabulary of tens or hundreds of thousands of tokens. Frequent sequences such as " the" or " payment" become single tokens. Unusual words, code identifiers and many non-Latin scripts break into more pieces.
Each model family has its own tokeniser, so the same sentence gives different counts on different models.
Example: counting real tokens
These counts use o200k_base, the encoding that OpenAI's open-source tiktoken library uses for GPT-4o. The | marks show token boundaries:
"Your refund will reach your account in 5 to 7 working days."
Your| refund| will| reach| your| account| in| | 5| to| | 7| working| days|.
12 words, 59 characters -> 15 tokens
"Idempotency keys stop duplicate payments."
Id|empot|ency| keys| stop| duplicate| payments|.
5 words -> 8 tokens
The refund sentence in Hindi, "आपका रिफ़ंड 5 से 7 कार्य दिवसों में आपके खाते में पहुँच जाएगा।", comes to 21 tokens for 13 words, because Devanagari splits into more pieces than English with this encoding. That matters for apps with Indian users: the same message uses more of the context window and costs more to process.
OpenAI's rule of thumb for English is about 4 characters, or three-quarters of a word, per token, so 100 tokens is roughly 75 words. Use it for estimates, and count exactly when it matters:
import tiktoken
enc = tiktoken.get_encoding("o200k_base")
len(enc.encode("Your refund will reach your account in 5 to 7 working days.")) # 15
Types of tokens on a usage report
- Input (prompt) tokens: everything you send, including the system prompt, history, documents and tool definitions.
- Output (completion) tokens: what the model generates. Providers usually charge more for these than for input.
- Cached input tokens: a repeated prompt prefix that the provider reuses through prompt caching, often billed at a lower rate.
- Reasoning tokens: internal steps a reasoning model works through before its visible answer. You don't see them, but they count as output.
- Special tokens: markers such as end-of-sequence (EOS) or message-role boundaries that structure the text for the model.
Settings such as max_tokens or max_output_tokens cap the length of one response. They don't change the model's context window.
Practical tips
- Log input, output and cached token counts for every request, and track cost per completed task rather than per call.
- Trim long system prompts and repeated history first, because you pay for them on every turn.
- Compare models on total tokens for a real task. A model with a lower rate per token may use more tokens to do the same job.
- Measure token counts in the languages your users actually write in, a habit that also helps FinOps forecasting.
Token use drives most LLM running costs, as our LLM chatbot cost guide explains.