AI basics
What are tokens in AI? Tokens and context windows explained
AI models read and write text in tokens: words or pieces of words. How tokenisation works, how many words a token is, what a context window is, and why tokens decide what AI costs.
Short answer
A token is the unit of text an AI language model reads and writes: often a whole short word, sometimes part of a longer word, a number or a punctuation mark. In English, one token is about four characters, or roughly three quarters of a word, so 100 tokens is about 75 words. A model's context window is the maximum number of tokens it can take in at once, and AI services usually charge per token.
What a token is
Before a language model can read your message, a program called a tokeniser chops it into pieces from a fixed vocabulary, often tens of thousands to a couple of hundred thousand entries. Each piece is a token, and each token has an ID number. The model only ever sees those numbers.
Common words get their own token. Rarer words are built from parts: "tokenisation" might become "token", "isation". A space is usually attached to the start of the next word, and numbers are often split into chunks of digits.
Try pasting a sentence into a free tokeniser tool, like OpenAI's, to watch it split. The tokenisation lesson shows how vocabularies are learned.
How many words is a token?
For ordinary English text, OpenAI's rule of thumb is that one token is about four characters, or about ¾ of a word:
- 1 token ≈ 4 characters ≈ ¾ of a word
- 100 tokens ≈ 75 words, about a paragraph
- 1,000 tokens ≈ 750 words, about a page and a half
- 100,000 tokens ≈ 75,000 words, a full-length novel
Other languages often take more tokens for the same meaning, because tokeniser vocabularies are built mostly from English-heavy text. Code, maths and unusual names can also use more tokens than you'd guess.
Why AI uses tokens instead of words or letters
Letters alone would make every text very long and slow to process. Whole words would need an enormous vocabulary and still fail on new words, typos and names. Subword tokens, usually built with a method called byte-pair encoding, are the compromise: common words stay whole, and anything else can still be spelled out from pieces.
Tokens explain some odd AI behaviour. Models have historically struggled to count the letters in a word, because they see "strawberry" as one or two tokens, not ten letters.
What is a context window?
The context window is the most tokens a model can handle in one go: your messages, any documents or instructions, the conversation so far and its own reply. Think of it as working memory. When a chat gets longer than the window, the oldest parts have to be dropped or summarised, which is why a long chat can "forget" what you said at the start.
Context windows have grown fast, from a couple of thousand tokens in early models to hundreds of thousands or more today. But a big window isn't perfect memory: models can miss details buried in the middle of very long inputs, and longer inputs cost more and run slower. That's why tools like RAG still pick only the most relevant passages.
Why tokens matter for cost and speed
- Price. AI APIs charge per million tokens, usually with separate prices for input and output. Output tokens often cost several times more.
- Speed. A model writes one token at a time, so a long answer takes longer. Speed is quoted in tokens per second.
- Limits. Maximum reply lengths and usage caps are set in tokens.
- Reasoning. Reasoning models "think" in tokens too, which is why harder questions can cost more. See test-time compute.
Key takeaways
- Models don't see letters or words; they see tokens, each mapped to a number.
- Rule of thumb for English: 1 token ≈ 4 characters ≈ ¾ of a word.
- The context window is the model's working memory, measured in tokens.
- Pricing, speed and limits are all counted in tokens, in and out.
Learn it properly, free
- How text becomes tokensIntermediate · 7 min
- Meet the chatbots: LLMsBeginner · 6 min
- How models are served: prefill, decode and the KV cacheAdvanced · 8 min
- Attention is all you needAdvanced · 8 min
Terms in this post
Questions
How many words is 1,000 tokens?
About 750 words of ordinary English text. The rule of thumb is that one token is roughly four characters, or three quarters of a word. Other languages and code usually take more tokens.
What is a token in ChatGPT?
A token is a piece of text ChatGPT reads or writes: a short word, part of a longer word, a number or punctuation. Your message is split into tokens, and the reply is generated one token at a time.
What is a context window in an LLM?
It's the maximum number of tokens the model can consider at once, including your input, the conversation history and its reply. Anything beyond it has to be dropped or summarised.
Why do AI models charge per token?
Because the computing work grows with the number of tokens processed and generated. Counting tokens is a fair, simple way to measure how much the model did.
Sources and further reading
- Tokenizer · OpenAI · Free tool
- Let's build the GPT Tokenizer · Andrej Karpathy · Free video
- Hugging Face LLM Course · Hugging Face · Free course