Services

Resources

Company

Token (LLM)

A token is the basic unit of text a large language model (LLM) processes. A tokenizer splits input into tokens, often whole words, parts of words or punctuation, and maps each one to a number. The model reads input tokens and generates output tokens one at a time. Context limits, latency and API pricing are all counted in tokens.

How to calculate it

Most modern tokenizers use byte pair encoding (BPE), which merges frequent character sequences into single tokens. A common rule of thumb for English is about 4 characters, or three quarters of a word, per token. A 1,000-word prompt is therefore roughly 1,300 tokens. At an example price of $3 per million input tokens, that prompt costs about $0.004. Output tokens are usually priced higher than input tokens.

Why it matters in production

Token counts set both the bill and the response time. Input tokens are processed in a prefill phase, while output tokens are generated one by one in a decode phase, so long answers add latency. Tracking input, output and cached tokens per request shows where cost comes from, and prompt caching can cut it.

See also

On the One2N blog

References

  1. Origin of the term

  2. Neural machine translation of rare words with subword units (Sennrich et al., 2016)

Comic about token (LLM): a shop's AI chatbot bill jumps from $5,000 in May to $8,000 in June with the same number of chats; the AI reads text in chunks called tokens, and you pay per token; Kai's bot instructions grew from 1,000 to 2,000 tokens, sent with 1M chats, costing $6,000; Kai cuts them to 500 tokens, $1,500, saving $4,500 a month and bringing the bill down to $3,500.