What is a token in an LLM? Counting, pricing and context
The short version
- A token is the unit an LLM reads and writes: a piece of text between a character and a word in size.
- LLM APIs bill by tokens, input and output separately. On many models an output token costs more than an input token.
- The same text comes out as a different number of tokens on different models, because each model has its own vocabulary.
- The reliable count is the
usagefield in the API response. It is counted by the model's own tokenizer.
Text becomes tokens before the model sees it
People read text as characters and words. A model first turns text into a list of tokens with a tokenizer, and most models use some form of BPE (byte pair encoding).
BPE starts from single characters and keeps merging the pairs that appear together most often in the training data, until it has a vocabulary of tens or hundreds of thousands of pieces. A common English word ends up as one token. A rare word splits into several.
Rough figures, which vary by model:
| Text | Tokens, roughly |
|---|---|
| A common English word | About 1 token (3 to 4 characters) |
| A Japanese character | 1 to 2 tokens |
| Punctuation, symbols, emoji | Often 1 token or more each |
Because vocabularies differ, "how many tokens is this prompt?" has no answer until you pick the model.
Why APIs bill by the token
The compute a model spends grows roughly with the number of tokens it handles. Reading a longer input and writing a longer output both cost more, so APIs charge by tokens rather than by request.
Billing has two parts:
- Input tokens (
prompt_tokens): everything you send. The system prompt, the conversation history and the question. - Output tokens (
completion_tokens): everything the model writes back.
Output is priced higher than input on many models, so a long answer often costs more than a long prompt. FastMetal bills the same way, per million input and output tokens; each model's rates are on the pricing page.
Counting tokens: read usage
People often want an exact count before sending. In practice the reliable number is usage in the response, because the model's own tokenizer produced it. It is a measurement.
curl https://api.fastmetal.ai/v1/chat/completions \
-H "Authorization: Bearer $FASTMETAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic-claude-haiku-4-5",
"messages": [
{"role": "user", "content": "What is a token? Answer in one sentence."}
]
}'
The response ends with a usage block like this one:
{
"usage": {
"prompt_tokens": 24,
"completion_tokens": 38,
"total_tokens": 62
}
}
prompt_tokens: input tokenscompletion_tokens: output tokenstotal_tokens: the two added together
The numbers are an example; yours depend on the model and the text. While you build, send a few representative prompts and log usage. Your cost estimate gets much closer to the real bill.
To estimate before sending, FastMetal also has a token counting endpoint. Billing still follows the usage of the real request.
Tokens and the context window
Every model has a limit on how many tokens it can handle in one request, input and output together. That limit is the context window.
In a chat, the whole history goes back as input on every call. It fills the window, and it also makes every call cost more than the one before. In practice the quiet climb in cost per request tends to bite before the hard limit does. What a context window is covers the limit in detail.
Some languages take more tokens
The same content often takes more tokens in a language other than English, because tokenizer vocabularies are built mostly from English text and split other scripts into smaller pieces. Japanese is a common example, at one to two tokens per character. The gap varies a lot between tokenizer generations and models, and your choice of model and how you write the prompt both narrow it.
Keeping token costs down
Once you see how tokens work, the levers are plain:
- Set the length of the answer. "Answer in under 100 words" holds down output tokens, the dearer kind on many models.
- Send only the history you need: the last few turns, or a summary of older ones.
- Match the model to the task. Classification and extraction often run fine on a small model.
- Keep measuring
usage, so you know from data which requests are heavy.
FAQ
How do tokens differ from characters?
Characters are the length of the text itself. Tokens are the pieces the model's tokenizer splits that text into. In English a token is a few characters; in Japanese one character is often one or two tokens. The same text can give different counts on different models.
Which costs more, input or output tokens?
Both are billed. On many models output tokens are priced higher than input, so asking for long answers moves your bill more than sending long prompts.
Can I know the exact count before sending?
The exact figure is the usage in the real response. A token counting endpoint gives an estimate in advance, but billing follows the usage of the actual request.
Summary
Tokens are the unit an LLM handles text in, and they set both what you pay and how much fits in one request. Measure them from usage and you manage cost with numbers. Read this with the Chat Completions API basics, then send a first request from the docs and look at its usage. Every model is listed in the model catalog.