A 1200-word system prompt, 200-word query, 150-word reply on GPT-5.5. Estimate the token cost, then name what doubles it.
A 1200-word system prompt, 200-word query, 150-word reply on GPT-5.5. Estimate the token cost, then name what doubles it.
Roughly 1,820 input plus 195 output tokens at 1.3 tokens/word on o200k_base. Doublers: tool schemas, conversation history, non-English input, JSON system data, CoT output. Validate with tiktoken.
Think of tokens like syllables a language model has to read or speak. English breaks into roughly 1.3 syllables per word in this model's dictionary. A 1,400-word prompt is about 1,820 syllables in, a 150-word reply is about 195 out. Multiply by the per-syllable price and you get your bill. But the real world adds five things that quietly double the count. Tools the model can call cost extra reading every time. Multi-turn conversations replay everything you said before on every reply. Hindi and Arabic users speak in many more syllables per word than English ones do. Structured data shoved into the prompt as JSON is wordier than the same content as prose. And if you ask the model to think out loud or reply in JSON, the answer balloons. Estimate with the heuristic, then check with the real counter before you trust the number.
Detailed answer & concept explanation~9 min readEverything 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. 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.
Walk the per-ticket arithmetic: 1.3 tokens/word for English on o200k_base, 1,820 input plus 195 output. Then list and explain the five doublers: tool schemas, conversation history, non-English fertility, JSON-formatted system data, structured or CoT output. Cover the validation discipline of running real prompts through tiktoken and reconciling against response.usage. Close with prompt caching as the production lever for long static system prompts.
import tiktoken
enc = tiktoken.get_encoding('o200k_base') # GPT-4o/GPT-5/GPT-5.5
system_prompt = open('support_system.md').read() # ~1200 words
user_msg = 'My order #12345 has not shipped, can you check?' # ~200 words
assistant_reply = generate_reply(...) # measured at runtime
n_input = len(enc.encode(system_prompt + user_msg))
n_output = len(enc.encode(assistant_reply))
print(f'input={n_input}, output={n_output}')
# Validate against actual API response
response = client.chat.completions.create(...)
print(response.usage.prompt_tokens, response.usage.completion_tokens)
# Drift between tiktoken count and response.usage indicates
# you missed the tool-schema or chat-template overhead.Real products, models, and research that use this idea.
- OpenAI's tiktoken library exposes get_encoding('o200k_base') for GPT-4o, GPT-5, and GPT-5.5 token counting; the per-language fertility numbers come from running it on representative samples.
- Anthropic's Claude messages.count_tokens and OpenAI's response.usage both expose actual input and output token counts post-request, which production teams reconcile against estimates nightly.
- OpenAI's prompt-caching pricing in 2026 charges discounted rates on cached prefixes, so long static system prompts only pay full price on the first occurrence, which production cost models need to account for.
- Customer-support agent platforms like Intercom Fin and Zendesk AI agents publish per-conversation cost ranges that explicitly call out tool count and multi-turn flow as the main cost drivers.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does OpenAI's prompt caching change the cost picture for a long static system prompt?
QYour traffic shifts to 40 percent Hindi users overnight. What happens to the bill and how do you respond?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Estimating from user-visible prompt length alone, missing the tool schema, the chat-template wrappers, and the conversation history that all count toward billed input tokens.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.