Tokens & Context Windows
What you'll learn
- Define a token and estimate token counts from words
- Explain what a context window is and why it matters
- Connect tokens to real dollar costs and answer quality
What a token actually is
Models don’t see words — they see tokens, chunks of text produced by a tokeniser. A token is roughly 4 characters or about ¾ of a word in English. Common words (“the”, “and”) are usually a single token; longer or rarer words split into several (“tokenisation” → token + isation), and every space and punctuation mark counts too. A handy estimate: words × 1.3 ≈ tokens.
Code, numbers, and non-English languages tokenise less efficiently, so the same visible length can cost noticeably more tokens.
The context window: the model’s working memory
Every model has a context window — the maximum number of tokens it can handle in one request, covering both your input and its output. Think of it as the desk space the model works on: everything it’s considering for this answer has to fit. Exceed it and the extra input is silently cut, which is a common cause of “why did it ignore the end of my document?”
Bigger windows help, but they aren’t a free pass. Models reliably use information at the start and end of a long context better than the middle — the “lost in the middle” effect — so burying the key fact in paragraph 40 of 80 is risky.
Tokens are the meter
Here’s why this lesson matters for your wallet: APIs bill per token, and input and output are priced separately (output usually costs several times more). Two consequences follow:
- Don’t resend everything. If you paste a 5,000-token document on every turn of a 20-message chat, you pay for it 20 times. Summarising old turns or retrieving only the relevant snippet is the fix.
- Cap the output. Verbose answers cost more and then re-enter the context on the next turn, compounding.
When you’re ready to turn this into real savings, the Token & Cost Optimization playbook has a live pricing table and the exact techniques. Next lesson: how models turn tokens into meaning with embeddings.
Roughly how many tokens is the following text, and how many words? Then explain the rule of thumb you used: "Large language models read and write in tokens, not words."
That sentence is about 12 words and roughly 15–16 tokens. Rule of thumb: for typical English, 1 token ≈ 4 characters ≈ 0.75 words, so words × 1.3 ≈ tokens. Short common words are often one token; longer or rarer words (and punctuation) split into several.
Sample output — AI responses may vary.
Common mistakes
- Counting words instead of tokens when estimating cost or fit — they differ by ~30%, and code or non-English text can differ far more.
- Assuming a bigger context window is always better. Models can lose track of details buried in the middle of a very long context ('lost in the middle').
- Pasting an entire document every turn. You re-pay for those tokens on every message; summarise or retrieve instead.
How to check the AI's answer
- Check the model's stated context-window size before pasting large inputs — anything over the limit is silently truncated.
- If answers about a long document get vague, the relevant part may have fallen outside the window or been buried; feed a focused excerpt.
Key terms
Test yourself
3 questions · answers reveal after you check.
1. Roughly how many tokens is 1,000 words of typical English?
A common rule of thumb is words × 1.3 ≈ tokens, so ~1,300 tokens for 1,000 words.
2. The 'context window' is…
It's the token budget for a single request — prompt plus response must fit inside it.
3. Why does pasting a whole document every turn get expensive?
Input tokens are billed each call. Resending a big document each turn multiplies the cost — retrieve or summarise instead.