What is a token in an LLM?
A token is the unit a language model reads and bills by. Here is what tokens are, how text splits into them, and why they drive your AI cost.
Updated
A token is the small unit of text that a language model reads and writes. Models do not work on whole sentences or single letters. They work on tokens, which are usually common words, pieces of longer words, numbers or punctuation marks. Providers measure your bill, the model’s reply speed and the size of each request in tokens, so you need this unit before you can estimate any AI cost.
How text becomes tokens
Before a model reads a prompt, a tokenizer cuts the text into pieces and gives each piece an ID. Short common words are usually one token. Long, rare or invented words split into several. Code, numbers, URLs and text in languages other than English often take more tokens than plain English prose of the same length.
Here is an illustration of one invoice reminder line. The exact pieces depend on the tokenizer, so read this as a picture of the idea, not a measurement:
- The line: Invoice 4471 is 12 days overdue.
- Possible pieces: Invoice, 44, 71, is, 12, days, overdue, and the full stop.
A line of plain English this short can still split into eight pieces, and the invoice number splits in two. An ID that looks short can cost more than you expect.
Each model has its own tokenizer. Two models can split the same paragraph into different counts, so a count from one provider does not predict another. If you change models, count again before you estimate the cost.
What you pay for
API providers charge per million tokens, and they bill input and output separately. Input is everything you send: the system prompt, instructions, documents, examples and earlier chat turns. Output is what the model writes back. Output is usually priced higher than input, so a verbose reply can cost more than a long prompt. For how per-million rates turn into a cost per task, read cost per million tokens, explained.
The usual surprise is input you did not think about. A system prompt that repeats on every call, a chat history that grows each turn and a retry after a failed request all bill as input tokens. A call inside a loop multiplies whatever it sends. A 2,000-token prompt sent 50,000 times is 100 million input tokens, even though each single call looks cheap.
Some providers charge less for work that can wait, such as overnight batch jobs. Check the current price sheet for each vendor, because rates and discount rules change.
Context windows and rate limits
Tokens also set how much a model can handle in one request. Each model has a context window, the largest number of tokens it can hold at once. The prompt and the reply both count against it. Take a window of 100,000 tokens and a 60,000-token contract. That leaves 40,000 tokens for instructions, examples and the answer. If the answer needs 30,000 tokens, the instructions get at most 10,000.
Rate limits are often counted in tokens too. A provider may cap how many tokens you can send per minute. A batch job can hit that cap well before it hits your budget, so check both limits before you plan a run.
Output length needs a limit as well. Set a maximum output size on every call, so one unusual input cannot produce a reply far longer than the task needs. Longer replies also finish later, because the model writes one token after another. Streaming makes the first words appear sooner, but the total time still grows with reply length. For the speed side, read tokens per second, explained.
Common mistakes
- Counting words instead of tokens. A word-count estimate can be far off for code, IDs and non-English text. Measure with the provider’s own token count on real inputs.
- Budgeting for one tokenizer and then switching vendors. The count changes, so update the estimate after the switch.
- Leaving output uncapped. One bad input can trigger a very long reply.
- Resending the full chat history on every turn. Summarize or trim older turns that the next step does not need.
- Cutting a prompt without testing it. A shorter prompt that gets worse answers costs more, because you pay for the errors and the review time that follows.
Our contract extraction test uses 510 documents with 5-fold cross-validation, so each prompt change is scored on answers, not token counts. A cheaper prompt that misses clauses is not a saving once someone has to fix the output. See full results on the benchmark page.
A checklist for measuring tokens
- Log the input and output token counts that each API response reports.
- Pull about 50 real inputs from production, not one clean example.
- Work out average input and output tokens per document, not per call.
- Set a maximum output length for each type of call.
- Score the prompt on your own labeled set before and after each trim.
- Recount tokens after any change of model, tokenizer or prompt template.
Trade-offs come with every saving. Removing examples lowers input tokens but can lower accuracy on unusual cases. Asking for JSON with fixed fields keeps replies short and easy to parse, but a strict schema can fail on inputs it did not anticipate, so test the edge cases. Prompt caching cuts repeated input cost only when the start of the prompt stays the same across calls. For how that works, read prompt caching savings.
If you want to see where your own tokens go, run the free AI cost audit or book a free call with Own Weights. The audit lists each AI call in your code, the model it uses and an estimated cost, so you can see which calls use the most tokens.
Questions
How many words is one token?
There is no fixed ratio. A token is often a short common word, but it can also be a fragment of a longer word, and the split depends on the tokenizer. Ask your provider's token counting tool to measure a real prompt.
Do input and output tokens cost the same?
No. Output tokens are usually priced higher than input tokens, so a verbose answer can cost more than a long prompt. Check each vendor's current price sheet, since list prices change and batch discounts vary.
Do more tokens make a model slower?
Yes. Answers are produced piece by piece, so a long reply finishes later than a short one, and a long prompt adds processing before the first piece appears. The setup you run on also changes the speed.