AI API cost calculator

Enter the tokens a call sends and receives and the two prices your provider quotes per million tokens. The calculator shows the cost of one call and of a whole run.

The prices are example values. Replace them with the rates your provider quotes.

Cost of the runEnter values to calculate

Input and output are two different bills

Providers quote a price per million input tokens and a separate, usually higher, price per million output tokens. A summarizing job that reads a long document and writes three sentences is dominated by the input side; a job that expands a short brief into pages is dominated by the output side. Blending the two into one rate hides which half of your workload is expensive, which is the half worth optimizing.

One call is cheap, which is the trap

A single call priced in thousandths of a cent reads as free, and that reading is what makes cost surprising later. The run figure exists to make the multiplication explicit: the same call that costs a fraction of a cent costs real money at ten thousand repetitions, and a background job that retries is doing more repetitions than you think.

The number to check against a provider invoice is the run, not the call. If they disagree, the usual causes are retries, a system prompt counted on every call, and output that ran longer than the sample you measured.

What this cannot see

Cached input, batch discounts, minimum billing units, image and audio tokens, and per-request fees all vary by provider and none of them are modelled here. This page does the arithmetic on the two prices you give it. Treat the result as the floor of a bill, not as the bill.

Frequently asked questions

Where do I find the token counts?

Providers return them in the response, usually as usage fields naming input and output tokens. Those counts are exact. Estimating them from a word count is fine for planning, but use the returned numbers when you are checking a bill.

Why is the result shown to four figures on small amounts?

Because rounding a call that costs $0.0081 to two decimals would print $0.01, a 23% error, and printing $0.00 would be worse. Small totals keep more digits; totals above a cent are shown to the cent.

Does this include cached or batched pricing?

No. Discounted cached input and batch tiers are priced differently by each provider and are not modelled. If your workload uses them, enter the effective rate you are actually charged for that portion.

Can I use it for a model that charges per character or per image?

Not directly. The arithmetic here is per token on two rates. A per-character or per-image price is a different unit and would need its own conversion before this page is any use.

More tools

Tokens & words

Estimate tokens from words at an adjustable ratio.

Context window

Room left once the answer has been reserved.