How LLM API pricing works
Large language model APIs bill by the token, not the request. A token is a chunk of text — roughly 4 characters or 0.75 words of English, so about 1,000 tokens per 750 words (code and non-English text run higher, and tokenizers differ: Anthropic notes its newest models tokenize the same text into ~30% more tokens than its earlier ones). Every model has two prices, quoted per 1 million tokens: one for input (everything you send — system prompt, retrieved context, the user's message, and any prior chat turns) and one for output (the model's reply).
Output is almost always the pricier of the two — typically 3× to 6× the input rate — because the model generates it one token at a time, while your input is processed in parallel. That single fact drives most of the surprises in a monthly bill: a short answer can cost more than a long prompt. The rates embedded here were verified in July 2026 against OpenAI's API pricing page, Anthropic's pricing documentation, and Google's Gemini API pricing page; if your model or negotiated rate isn't listed, pick "Custom pricing" and enter your own numbers.
The formula
Tin and Tout are input and output tokens per request; Pin and Pout are the model's prices per million tokens; R is requests per day. We use a 30.44-day month (365.25 ÷ 12, the average calendar month) so monthly and annual figures line up. These are standard pay-as-you-go rates: batch and caching discounts are deliberately excluded (see below), so treat the result as your ceiling, not your floor.
Worked example
A product assistant sends 1,500 input tokens (system prompt + context + the user's question) and gets back a 500-token answer, over 1,000 requests a day.
On Claude Sonnet 4.6 ($3 / $15 per 1M): (1,500 × $3 + 500 × $15) ÷ 1,000,000 = $0.012 per request → × 1,000 × 30.44 = $365.28 / month. Note the output is $0.0075 of that $0.012 — 62.5% of the cost from 25% of the tokens.
The same workload runs about $10.65 / month on Gemini 2.5 Flash-Lite, $121.76 on Claude Haiku 4.5, and $1,217.60 on Claude Fable 5 — a >100× spread for identical traffic. Model choice is the second-biggest lever after output length.
The cost levers that actually move the bill
Output length is the big one. Because output is priced highest and you pay per generated token, trimming a verbose reply from 800 to 400 tokens roughly halves the output cost — often a bigger saving than any prompt tweak. Ask for concise answers, set a sensible max_tokens, and avoid letting the model pad. Model choice is second: the spread between the cheapest and priciest models on the same workload can be 20× to 100×, so route easy calls to a small model and reserve a frontier model for the hard ones. Batch and caching are the third lever, and this calculator deliberately ignores them: prompt caching bills repeated system prompts and context at roughly 10% of the input rate, and batch APIs cut both input and output by about 50% for work that can wait — combined, stable high-volume workloads routinely save 50–90% versus the standard rates shown here. If you want to sanity-check a percentage saving, the percentage calculator handles the arithmetic.
The hidden costs that break naive estimates
Three things routinely make a real bill exceed the back-of-envelope figure. Retries: timeouts and rate-limit backoffs mean some requests run more than once — budget a few percent of overhead. System prompts count as input on every single call: a 1,500-token system prompt sent 1,000 times a day is 1.5 million input tokens daily before the user types anything — exactly what prompt caching exists to defray. Context growth in multi-turn chats: because you resend the whole conversation each turn, a 10-turn chat pays for early messages 10 times over, so a flat per-request estimate undercounts long sessions. One more thing money can't fix: rate limits are separate from cost. Every provider caps requests and tokens per minute by usage tier, so a workload you can afford is not automatically a workload you're allowed to run — check the tier limits before promising throughput.
Build vs. API: the honest breakeven
At some monthly bill, self-hosting an open-weight model starts to look tempting. The honest math: a single always-on GPU server capable of serving a decent model rents for more per month than most of the workloads people run through this calculator, and that's before an engineer's time to run it. Self-hosting wins on unit cost only when you can keep expensive hardware busy around the clock — sustained, high, predictable volume — or when the small models you'd run are dramatically cheaper than the frontier model you'd otherwise call. Below that, the API's pay-per-token model is the discount. The better reasons to self-host are privacy, latency control, and independence, not the invoice; to compare a monthly bill against an upfront hardware spend properly, the time value of money calculator is the right next stop.
The vintage caveat: prices move
This calculator reflects published standard rates as of July 2026, verified against OpenAI's API pricing page, Anthropic's pricing documentation, and Google's Gemini API pricing page. LLM pricing is unusually volatile — new model tiers launch monthly, introductory discounts expire, and per-token rates get cut as capacity grows. Two specific things to check before you commit a budget: introductory pricing (Anthropic's Claude Sonnet 5 runs at its $2 / $10 intro rate only through 31 August 2026, then reverts to $3 / $15) and long-context surcharges (Google's Gemini Pro models charge roughly double per token once a prompt exceeds 200K tokens). Always re-check the provider's current pricing page before budgeting a production workload.