How to Calculate AI API Cost
Token spend per request, per user and at scale, including cache savings.
How this number is built
Calculating it yourself
Step 1
Measure real token counts from a sample of production requests.
Step 2
Separate input from output — they are priced very differently.
Step 3
Apply prompt caching to the stable portion of your context.
Step 4
Divide by requests and by active users to get the two unit numbers that matter.
Step 5
Model a traffic multiple so a growth spike does not surprise the budget.
What people ask next
How do I reduce cost fastest?
Shorten outputs, cache the static prompt prefix, and route simple requests to a smaller model.
Are tokens the same as words?
No. English text averages roughly three-quarters of a word per token, and code is denser than prose.
Searches this page answers
| Related search | Goes to |
|---|---|
| openai python sdk | AI API Cost Calculator |
| openai gpt-4.1 pricing | AI API Cost Calculator |
| openai codex github | AI API Cost Calculator |
| openreview | AI API Cost Calculator |
Tools that follow from this one
ROI & Payback Calculator
Return, annualised return and payback period for any investment or project.
Business & TechBreak-Even Point Calculator
Units and revenue needed to cover fixed costs, plus margin of safety.
Business & TechCAC & LTV Calculator
Customer acquisition cost, lifetime value and the ratio investors ask about.
Business & TechHosting & Cloud Cost Calculator
Monthly infrastructure spend across compute, bandwidth, storage and support.