Skip to content
mathbehind

How to Estimate LLM API Costs Before You Ship

API bills come from input and output tokens priced separately. With three numbers per request you can estimate a monthly bill and compare models before writing any code.

By Muhammad Ahmad. Published . 2 min read.

Want to run your own numbers?AI API Cost CalculatorOpen the calculator

AI model APIs from OpenAI, Anthropic and Google all bill the same way: by tokens, with a separate price for the tokens you send (input) and the tokens the model writes back (output). Prices are quoted per million tokens.

That means you can estimate a monthly bill with only three numbers: input tokens per request, output tokens per request, and requests per month.

Step 1: Estimate tokens per request

Input tokens include everything you send: your instructions, the user's message, any documents you include, and earlier turns of the conversation. Output tokens are the reply.

If you only know word counts, a good rule of thumb for English text is that 1,000 tokens is about 750 words. Code and other languages usually need more tokens per word.

Step 2: Price one request

Divide each token count by one million and multiply by that model's rate. Here is a request with 5,000 input tokens and 1,000 output tokens on Claude Sonnet 5, at $2 per million input tokens and $10 per million output tokens.

One request, then a month of them
  1. Input

    5,000 ÷ 1M × $2.00equals$0.010

  2. Output

    1,000 ÷ 1M × $10.00equals$0.010

  3. Per month

    $0.020 × 10,000equals$200.00

Step 3: Compare models

The same workload costs very different amounts on different models. Using the prices in our calculator's dataset (checked 16 September 2026), 10,000 of those requests a month would cost about:

  • Claude Sonnet 5: $200
  • Claude Haiku 4.5: $100
  • GPT-5.6 Luna: $22

A cheaper model is not automatically the right choice. Test whether it handles your task well enough first, then let cost decide between the models that pass.

Why output tokens matter more

Output is usually priced several times higher than input. In the example above, 1,000 output tokens cost as much as 5,000 input tokens. If the replies grow to 3,000 tokens, the cost per request doubles to $0.04 and the monthly bill to $400, even though the input did not change.

That makes asking for shorter answers, or setting a maximum output length, one of the most effective ways to cut costs.

What this estimate leaves out

  • Prompt caching, which can cut the cost of repeated input such as a long system prompt.
  • Batch processing discounts for work that does not need an instant answer.
  • Retries after errors, which you pay for too.
  • Conversation history: in a chat, every new turn resends earlier messages as input.

Tip: Prices change often. Check the provider's own pricing page before you commit a budget, and recheck it every few months.