Bytes, characters, tokens: which one gets billed and how do they relate?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Billing is per token, not per byte or character. The byte to token ratio is content-dependent and model-specific; only the model's tokenizer tells you the exact count.
Imagine a courier that charges by parcels, not by weight. You arrive with a bag of stuff and the courier breaks it into parcels according to their own rules. English text packs neatly: about 3 to 4 characters per parcel. Minified JSON or Python code does not pack neatly, because the courier's rules were built for prose and weird punctuation breaks at the seams. Hindi or Japanese characters use up parcels at a different rate again, because the rules learned during training were trained on mostly-English text and never saw enough non-Latin characters to compress them well. So 1 KB of English costs about 250 parcels; the same 1 KB of code or non-English text can cost twice as much. The only way to know your real bill is to run the courier's own ruler over your specific bag.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: distinguish bytes, characters, and tokens, state that billing is per token, explain BPE produces content-dependent compression ratios, give numbers for English vs code vs non-Latin text, and name the canonical tools for accurate counting.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Estimating cost by character count. Tokenizers compress differently across content types, so character-based estimates can be off by 2x or more for code and non-Latin text.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.