Riven

Prompt Cost Estimator: The Formula, Worked

The cost of one call is input tokens divided by one million, times the input rate, plus output tokens divided by one million, times the output rate. Multiply by calls per day and by 30.44 for a monthly figure. Because output is typically priced several times higher than input, the reply length usually dominates the bill on short prompts.

The formula and why output dominates

Per-call cost equals input tokens over one million times the input rate, plus output tokens over one million times the output rate. On most published price sheets the output rate is three to five times the input rate, so a short prompt with a long answer costs more than a long document with a short summary.

That inverts the intuition most people bring. Optimising prompt length helps, but capping reply length and stopping generation early helps more whenever the answer is allowed to be short.

Worked examples

A 1,500-token prompt with a 500-token reply, at $3 input and $15 output per million: input costs $0.0045 and output costs $0.0075, so $0.012 per call. At 1,000 calls a day that is $12 a day, about $365 a month.

Hold the input fixed and double the reply to 1,000 tokens: output alone becomes $0.015 and the call is $0.0195, a 62 percent rise for the same prompt. That is the lever worth pulling first.

Where estimates go wrong

Three things push real spend above the estimate: hidden system prompts and tool schemas, retries and failed calls that are still billed, and caching that is assumed but not actually enabled.

Measure one real call end to end, including the system prompt and tool schema, then scale. An estimate built from the user message alone typically undercounts by a wide margin.

Reconciling the estimate against a real invoice

An estimate built from the formula is a planning number, not a bill. Reconcile once: take a single day of real usage, multiply measured per-call cost by the actual call count, and compare against the provider invoice line for that day. If the two disagree by more than a few percent, the gap is almost always retries, a longer system prompt than assumed, or output that ran to the token cap.

Store the measured ratio next to the estimate. Once a workload has a measured ratio, every future estimate for that workload is simply measured cost times volume, which is far more reliable than re-deriving it from token counts each time.

Per-call cost at $3 input / $15 output per million tokens

Input tokensOutput tokensInput costOutput costPer call
500200$0.0015$0.0030$0.0045
1,500500$0.0045$0.0075$0.0120
1,5001,000$0.0045$0.0150$0.0195
8,0001,000$0.0240$0.0150$0.0390
30,0001,000$0.0900$0.0150$0.1050

Monthly cost at 1,000 calls per day

Per-call costPer dayPer monthPer year
$0.0045$4.50$137$1,644
$0.0120$12.00$365$4,383
$0.0195$19.50$594$7,123
$0.0390$39.00$1,187$14,247
$0.1050$105.00$3,196$38,355

What moves the bill most

LeverEffectEffort
Cap reply lengthHigh — output is priced highestLow
Trim retrieved contextMedium to high on RAG workloadsMedium
Prompt cachingHigh when the same prefix repeatsMedium
Cheaper lane for tolerant workHigh, and usually the quickest winLow

Frequently asked questions

Is the estimate exact?

No. It is arithmetic on rates you supply. Real bills differ through retries, caching behaviour, and cached-versus-uncached rates, so treat the output as a planning figure and reconcile against one real invoice.

Should I optimise prompt or reply length?

Reply length first, unless your prompts are very large. Output is priced several times higher than input on most price sheets, so a shorter answer saves more per token removed.

How do retries affect the estimate?

Every retry is another billed call, so a workload that retries once on ten percent of requests costs about ten percent more than the formula suggests. Instrument retry counts before trusting any per-call estimate.

More in tools

Sources and read dates

Related reading