Before you send a big prompt to an API model, it helps to know roughly what it will cost. The math is short. The part people get wrong is what counts as input and what counts as output.
The formula
cost = (input tokens / 1,000,000) x input price + (output tokens / 1,000,000) x output price
Providers list prices per million tokens, and output is priced higher than input, usually by a factor of three to eight. So a long prompt with a short answer can cost less than a short prompt that asks for a long essay.
Three things that change the number
- Your system prompt counts every call. If it is 1,500 tokens and you make 10,000 calls a day, that is 15 million input tokens before anyone types anything.
- Chat history is re-sent. In a multi-turn chat, each turn pays for all earlier turns again as input, so cost per message grows as the conversation grows.
- Reasoning models bill their thinking as output. The visible answer can be 300 tokens while the billed output is several thousand.
Rough token counts
For English text, about 4 characters is one token, or about 0.75 words. Code and non-English text usually take more tokens per word. Treat this as an estimate. Each model has its own tokenizer, so exact counts differ.
A worked example (made-up prices, use your provider's real ones)
Say input is $2.00 per million and output is $8.00 per million. A call with 3,000 input tokens and 500 output tokens costs:
3,000 / 1,000,000 x 2.00 = $0.006
500 / 1,000,000 x 8.00 = $0.004
Total = $0.010, one cent.
At 50,000 calls a month that is $500. Cutting the system prompt by a third would save about $100 of that.
A free calculator
I built a small page that does this in the browser: paste a prompt, pick a model, set the expected output length, and it shows the cost. It runs client-side, so your text is not sent anywhere. The prices on the page carry a "checked on" date because providers change them often, so confirm against the official pricing page before you budget.
https://kyb-api-toolkit.github.io/tools/ai-token-cost-calculator/
The page has one ad banner. If a model or price is missing or wrong, tell me and I will fix it.
Top comments (0)