guides

How to estimate LLM API cost before you build

Turn token rates, request volume, output length, and cache assumptions into a monthly budget you can test.

ai-cost pricing planning
Token volumes branching into several budget scenarios beside a calculator

Short answer: estimate an LLM API bill from four measured inputs: requests per day, tokens per request, the input/output split, and the provider’s current price per million tokens. Calculate a baseline month, then test higher traffic, longer replies, and lower cache reuse separately.

The monthly LLM API cost formula

For a model with separate input and output prices, use:

Monthly cost = (monthly input tokens ÷ 1,000,000 × input rate) + (monthly output tokens ÷ 1,000,000 × output rate).

Monthly tokens come from requests per day × tokens per request × billing days. The token mix then divides that total between input and output. This method is more reliable than multiplying one “average token price” because the two rates can differ substantially.

A worked example you can reproduce

Assume a hypothetical service processes 1,000 requests a day, averages 2,000 total tokens per request, and runs every day for a 30-day month. That produces 60 million tokens. If logs suggest a 70% input and 30% output mix, the month contains 42 million input tokens and 18 million output tokens.

With a hypothetical list price of $2 per million input tokens and $10 per million output tokens, the calculation is:

  • Input: 42 × $2 = $84
  • Output: 18 × $10 = $180
  • Baseline month: $264
  • Ten-times traffic stress test: $2,640

The example is deliberately hypothetical. Replace both rates with the numbers shown on the provider’s current pricing page. CostUse’s AI model price table applies the same 70/30 baseline across the catalog, while each model page lets you enter your own mix.

Measure the workload before choosing a model

  1. Capture real prompts and replies. Samples from the intended workflow are more useful than a generic word count.
  2. Count every repeated token. System instructions, conversation history, retrieved passages, tool results, and structured output all contribute to the request.
  3. Separate input from output. Do not assume chat, extraction, and long-form generation share the same ratio.
  4. Use more than one traffic band. Price the expected month, a quiet month, and a surge month.
  5. Record the source and date. OpenAI, Anthropic, and Google maintain separate official pricing pages, and rates or billing modes can change.

Costs the simple formula does not include

A token calculation is only the model portion of a production budget. Add storage, retrieval, reranking, web search, image or audio processing, observability, retries, and network services when the architecture uses them. Also check whether the provider applies different rates to cached input, batch processing, priority requests, long contexts, regions, or fine-tuned models.

Official references: OpenAI API pricing, Claude pricing, and Gemini API pricing.

A practical budget checklist

  • Use production-like samples, not a single short prompt.
  • Calculate input and output separately.
  • Model retries and failed calls instead of assuming every request succeeds once.
  • Apply cache savings only to traffic that meets the provider’s eligibility rules.
  • Keep a contingency line for traffic and response-length drift.
  • Recheck the public source before approving spend.

What should you do next?

Start with one measured workflow and one month, not the whole product. Enter its request count, token volume, and input/output mix in the relevant calculator. Once the baseline is credible, compare alternative models using exactly the same workload and repeat the calculation whenever pricing or product behavior changes.