Topic 2 of 5 · 4 min read
Tokens drive cost, limits and speed
Goal: Estimate the token cost of a task from its input and output size and say which part dominates the bill.
Tokens are the unit of account for AI: price, context limit, rate limit and answer length are all counted in tokens, and input and output are usually priced differently. If you can count tokens, you can predict the bill and the limits before you hit them.
Check yourself · 1 of 3
Which of these is counted in tokens?
Why it matters
A chat subscription hides tokens, but the limits are still there: a long chat slows down, the model forgets the start, or the tool tells you the conversation is too long. Through an API or a tool such as Cursor or Copilot, tokens turn into money and waiting time. A task that looks small can be expensive if it repeats thousands of times.
The four things tokens control
- Cost. Providers price per million tokens. Most charge more for output tokens (the answer) than for input tokens (your prompt and files). Some offer a lower price for repeated input that is cached. Read your provider's price page, because prices change.
- Context window. This is the most the model can hold at once: your instructions, the chat so far, pasted files and the answer, all added together. When it is full, old content is dropped or the request fails.
- Rate limits. Providers cap how many tokens you may use per minute. A big prompt sent many times can hit the cap before the request count does.
- Speed. The model writes its answer one token at a time. A longer answer takes longer, and a very long input also slows the first reply.
How to estimate a task
Count the tokens in, count the tokens out, and multiply each by its price. Then ask which side is bigger.
The numbers below are made up for practice. Use your provider's real prices.
| Item | Tokens | Practice price per million | Cost |
|---|---|---|---|
| Input: a 20,000-token contract plus instructions | 20,000 | $3 | $0.06 |
| Output: a 500-token summary | 500 | $15 | $0.0075 |
Here the input is most of the bill, even though output costs five times more per token. Run it on 1,000 contracts and the input costs $60 and the output about $7.50. If you ask for a 4,000-token rewrite instead of a summary, the output side jumps to $60 per 1,000 contracts and becomes equal to the input.
Before and after
Before: Paste the full 200-page handbook into every question, so each answer re-reads it.
After: Paste only the relevant chapter, or use a tool that caches the long fixed part, and ask for a short answer.
What goes wrong
- People forget that a chat re-sends the whole history on every turn, so a long conversation costs more with each message.
- People set the answer limit too low, and the reply stops in the middle of a sentence.
- People compare models by price per token alone. A cheaper model that needs three tries can cost more than one that gets it right the first time.
Examples
Which side dominates?
A support team sends each customer email (300 tokens) plus a 3,000-token policy document, and asks for a 150-token reply. Input is 3,300 tokens, output is 150. Even if output costs five times more per token, input is about 22 times larger, so input dominates. The fix is to trim or cache the policy, not to shorten the reply.
Reading a full context window
A model has a context window of 100,000 tokens. Your pasted report uses 90,000 and you ask for a long answer. Only about 10,000 tokens are left for the instructions and the reply together, so the answer may be cut short or the request refused. Shorten the input before you ask.
Key points
- Price, context window, rate limits and answer length are all measured in tokens.
- Output tokens usually cost more per token than input tokens, but long input often dominates the bill.
- The context window holds your prompt, the chat history, pasted files and the answer together.
- Chats re-send history on each turn, so long conversations get more expensive and slower.
- Estimate a task by counting tokens in and out and multiplying by the provider's current prices.
Common mistakes
- Comparing models only by price per token and ignoring how many tries a task needs.
- Forgetting that chat history and system instructions are billed as input on every turn.
- Setting the maximum answer length too low and getting a reply that stops mid-sentence.
- Using last year's prices from memory instead of the provider's current price page.
Check yourself · 2 of 3
A chat has run for 80 turns and every new reply is slower and more expensive. What is the most likely reason?
Check yourself · 3 of 3
You send a 12,000-token document and get a 300-token summary. Output costs more per token than input. Which side most likely dominates the bill?
Practice items, not counted towards your mastery.
Start here
- Tokenizer (OpenAI) (opens in a new tab)ToolFree
Paste any text and see the token boundaries and count, coloured piece by piece.
- Tiktokenizer (compare tokenizers) (opens in a new tab)ToolFree
Switch between model tokenizers and see how the same text splits differently.
- Andrej Karpathy: minbpe and the GPT tokenizer lecture (opens in a new tab)ToolFree
A small tokenizer you can read, plus the lecture in text and video form on why spelling, arithmetic and non-English text go wrong.
More for this topic
- Token counting (Claude docs) (opens in a new tab)DocsFree
How to count tokens for a request before sending it, and what the usage fields mean.
- What are tokens and how to count them (OpenAI Help) (opens in a new tab)ArticleFree
OpenAI's short page with the English rule of thumb and how to read token counts.