▶ Sign up free for the video, slides & prompts
The lesson below is open to all. Enter your email once to unlock every video, slide deck, prompt and code example on this device.
Checking…
How LLMs Really Work · Lesson 6 of 15 · 2 min read · 5 min video
Tokens, context windows and cost
What a token is, why context has limits, and how to estimate an API bill.
📄 Download slides (PDF)· free sign-upModels don't see words, they see tokens. Tokens decide how much text fits in a request, how fast you get an answer, and what your bill looks like.
What a token is
A token is a chunk of text from the model's vocabulary, built so common pieces get their own entry:
- Common English words are usually one token: "the", "beach"
- Rarer words split: "Visakhapatnam" might be 4 or 5 tokens
- Spaces and punctuation count too
A rough guide for English: 1 token ≈ 4 characters ≈ ¾ of a word, so 1,000 words ≈ 1,300 tokens.
Indian languages cost more
Telugu, Hindi and other Indian scripts were less common in training data, so they often split into many more tokens for the same meaning. Sometimes several times more. Same message, higher cost, and the context window fills faster. Newer tokenizers are improving this, so measure with your actual model.
The context window
The context window is the maximum tokens a model handles in one call: your instructions, the chat history, any documents, and the answer it writes.
- Windows range from a few thousand tokens to a million or more, depending on the model
- When a chat gets too long, apps drop or summarise older messages, which is why a model "forgets" the start
- Even within the limit, models can pay less attention to details buried in the middle of very long inputs
Bigger isn't automatically better. Sending 200 pages when 3 are relevant is slower, costlier and often less accurate.
How API pricing works
You pay per million tokens, with separate rates for:
- Input tokens: everything you send
- Output tokens: everything the model writes, usually several times pricier than input
- Cached input: many providers charge much less for a repeated prompt prefix
Estimate before you build
A support bot that answers 2,000 questions a day, each with 1,500 input tokens (instructions plus retrieved docs) and 300 output tokens:
- Input: 2,000 × 1,500 = 3 million tokens a day
- Output: 2,000 × 300 = 0.6 million tokens a day
Multiply by your model's current prices, then by 30. Do this on day one, and again whenever you change models.
Cutting cost
- Use the smallest model that passes your tests
- Send only relevant context (good retrieval beats huge prompts)
- Keep instructions short, and put the fixed part first so it can be cached
- Cap the answer length
In one line
Tokens are the unit of everything: what fits in the context window, how fast replies come, and what you pay, so measure them early and send only what matters.
Share with a friend