Services

Resources

Company

/

Token (LLM)

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)

Three rows about LLM tokens. First, the text 'The deploy failed again!' is split into tokens The, deploy, fail, ed, again and the exclamation mark, each mapped to one number. Second, 1,000 words becomes about 1,300 tokens, which at $3 per million input tokens costs about $0.004. Third, input tokens are read in one pass while output tokens arrive one at a time and are priced higher, in red.

Putting this into practice?

Talk to One2N about our AI engineering services

Talk to One2N about our AI engineering services