$NoRefund

LLM cost calculator: the real formula

Cost = (input tokens ÷ 1,000,000) × input price, plus (output tokens ÷ 1,000,000) × output price. Input tokens are exactly countable before you call anything. Output tokens are the one number you have to estimate. A worked example, using real published pricing, is below.

The formula

Every major provider prices its models per million tokens, separately for input and output. The calculation itself is simple arithmetic once you have the token counts:

input_cost  = (input_tokens  / 1,000,000) * input_price_per_million
output_cost = (output_tokens / 1,000,000) * output_price_per_million
total_cost  = input_cost + output_cost

The part that is not simple is getting an accurate input token count in the first place, since every model family tokenizes text differently. That is the actual hard problem; the pricing math after it is trivial. See Mathematics for the exact implementation, including the long-context branch below.

Long-context pricing

Several providers charge more once a single request crosses a length threshold, commonly around 200,000 tokens. GPT-5.6 Sol, for example, charges $4 per million input tokens and $20 per million output tokens under 272,000 tokens of context, and $8 / $30 per million at or above it. The higher rate applies to the whole request once the threshold is crossed, not just the portion past it.

A worked example, with real pricing

This project's own 882-word architecture guide tokenizes to 1,951 tokens against GPT-5.6 Sol's tokenizer, well under any long-context threshold. At the standard rate of $4 per million input tokens:

Input tokens1,951
Input price$4.00 per million tokens
Input cost1,951 ÷ 1,000,000 × $4.00 = $0.007804
Assumed output500 tokens (a short summary reply, your real number will vary)
Output price$20.00 per million tokens
Output cost500 ÷ 1,000,000 × $20.00 = $0.010000
Total estimated cost$0.017804

The input side of that number is exact, since the token count is exact and the price is fixed. The output side is a placeholder, since nobody, including the model itself, knows the exact reply length in advance. That is why NoRefund lets you set your own expected-output-tokens default in Settings rather than guessing one number for every request.

Doing this for your own documents

Install NoRefund, open the Token Calculator for a quick "what if," or the File Parser to run this same calculation across a real file or a whole folder, against any of the 22 models in the registry. See the Claude vs GPT token count comparison for how token counts themselves differ by provider before the pricing is even applied.