Back to glossary

Term

Tokenizer

A tokenizer is the program that splits text into tokens before a language model can process it — it determines how many tokens a piece of text costs.

Tokenizer — explained in detail

Before a language model can read a prompt, the text must be split into tokens — small units that usually correspond to word fragments. That is the tokenizer’s job. Each model family ships its own: OpenAI’s GPT models use tiktoken, Anthropic’s Claude models switched to a new tokenizer with Opus 4.7, Meta models use SentencePiece variants. Because different tokenizers split the same text into different numbers of tokens, the cost per request varies across models — even when the per-token price is identical.

Practical relevance

A concrete example: Opus 4.7 uses a new tokenizer that produces up to 35% more tokens from the same text compared to Opus 4.6’s tokenizer. The per-token price is identical ($5 / MTok input, $25 / MTok output), but the real cost per request rises by up to 35% because more tokens are generated. Code and structured data are hit hardest. Knowing the tokenizer characteristics of your model lets you shorten prompts, use caching more effectively, and estimate actual costs more accurately.

A tokenizer is not the same as a token: the tokenizer is the tool, the token is the result. Also not to be confused with embeddings — those are created after tokenization, when the model converts tokens into numerical vectors.

Entdecke mehr