How to Estimate LLM API Costs

Most LLM APIs charge for the tokens you send and the tokens the model returns. A budget is three numbers multiplied together: tokens, price and volume.

The method

  1. Measure input tokens. Count everything you send in one request: the system prompt, the user message, any documents or retrieved context, and prior conversation turns if you resend them.
  2. Estimate output tokens. Look at real responses from your prompt. If you set a maximum output length, that is your upper bound.
  3. Find the prices. Providers publish a price per million tokens, usually with separate rates for input and output. Take them from the official pricing page for your exact model, since they change.
  4. Calculate one request. (input tokens ÷ 1,000,000 × input price) + (output tokens ÷ 1,000,000 × output price).
  5. Scale by volume. Multiply by requests per day, then by the days you want to budget for.

A worked example

Take illustrative prices of $3 per million input tokens and $15 per million output tokens. A request with 1,000 input and 500 output tokens costs $0.003 + $0.0075 = $0.0105. At 100 requests a day that is $1.05 a day, or $31.50 over 30 days. These prices are examples, not any provider's real rates.

What makes real bills higher than estimates

Ways providers may reduce cost

Some providers offer discounts for caching repeated prompt content or for batch processing. Availability and rules differ, so read the current documentation before assuming any discount in your estimate.

Try it

Use the token counter for a rough input size, then enter your numbers in the cost calculator. For background on token counts, read How Tokenization Works.