Tokens are the fundamental unit of API billing and context management. OpenAI uses tiktoken, a fast BPE (Byte Pair Encoding) tokenizer. Understanding token counts helps you manage costs and stay within context windows.
Encoding by Model Family
| Encoding | Models |
|---|---|
o200k_base | gpt-5.x, gpt-4o, gpt-4.1, o3, o4-mini |
cl100k_base | gpt-4, gpt-3.5-turbo, text-embedding-3-* |
p50k_base | Codex models, davinci/curie (legacy) |
Prompt Caching
Identical prompt prefixes are automatically cached server-side. Cache hits are charged at approximately 10% of the input price. For example, gpt-5.4 cached input costs $0.25/1M tokens vs. $2.50/1M standard. Use prompt_cache_key and prompt_cache_retention: "24h" to optimize cache hit rates.
Why Korean and Japanese tokenize hotter
The default English tokenizer (cl100k_base / o200k_base) was trained on English-heavy corpora. Latin-script languages average ~4 chars per token. CJK languages average ~1.5 chars per token because each CJK character often consumes its own token slot. A 1000-character Korean prompt can be 600+ tokens — roughly 2x what an English speaker eyeballing the length would expect.
The practical consequence: a multi-lingual app can have wildly different per-user costs for the same product behavior. Either budget per-language or use server-side prompt caching aggressively to amortize the system-prompt portion.