How is token cost calculated?
Two numbers drive every estimate: how many tokens you send (input) and how many the model returns (output). Each has its own price, quoted per 1,000,000 tokens.
The formula:
``` cost = (input_tokens / 1,000,000) * input_price_per_M + (output_tokens / 1,000,000) * output_price_per_M ```
To estimate token counts before you have an exact tokenizer count, use the rule of thumb that 1 token is approximately 4 characters or about 0.75 words in English (a rough estimate per OpenAI and Anthropic documentation). So a 500-word prompt is roughly 500 ÷ 0.75 ≈ 667 input tokens. This is an approximation; whitespace, punctuation, code, and non-English text shift the ratio.
Output dominates many bills because output prices are typically several times the input price, and long generations add up fast. If a task can return a short structured answer instead of prose, that alone cuts cost.