Skip to content
Built in Lahore, PakistanHow we check the math
mathbehind

How to Estimate and Reduce LLM API Costs

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, Software EngineerLinkedIn· figures checked

Published , updated . 4 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 (last checked 29 September 2026), 10,000 of those requests a month would cost about:

  • Claude Opus 5.5: $400
  • Claude Sonnet 5 and GPT-6 Sol: $200 each
  • Claude Haiku 4.5: $100
  • GPT-5.6 Luna: $22
  • GPT-6 Luna: $10

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.

Six ways to reduce the bill

Once you have an estimate, each part of it has a lever, and most can be pulled without users noticing.

  1. Pick the smallest model that passes your tests. The same chatbot workload costs $391.20 a month on Claude Sonnet 5 and $19.56 on GPT-6 Luna.
  2. Limit chat history, by keeping only recent turns or summarizing older ones (see the example below).
  3. Cache repeated input. Long system prompts and documents are sent with every request, and providers discount cached input heavily; OpenAI bills cached reads at 10% of the standard input rate on current models.
  4. Batch work that can wait. Batch APIs typically halve the price for jobs that can finish within 24 hours, such as nightly summaries or classification.
  5. Cap output length. Output tokens cost several times more than input, so ask for concise answers and set a maximum.
  6. Route by difficulty. Send simple requests to a cheap model and only hard ones to an expensive one.
The same chat at 12 messages instead of 6
  1. Input tokens

    12 × 800 + 12 × 60 + 360 × 12 × 11 ÷ 2equals34,080

  2. Output tokens

    12 × 300equals3,600

  3. Per conversation

    34,080 ÷ 1M × $2.00 + 3,600 ÷ 1M × $10.00equals$0.1042

  4. Per month

    $0.1042 × 10,000 conversationsequals$1,041.60

Doubling conversation length raised the monthly bill from $391.20 to $1,041.60, because every message resends the conversation so far.

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.

What caching and batch processing save

Using the AI API Cost Calculator's default workload on Claude Sonnet 5 (10,000 requests of 5,000 input and 1,000 output tokens): the standard cost is $200 a month. Caching 80% of each prompt and running the work through the batch API at half price brings it to about $64, a saving of $136. For work that doesn't need an instant answer, such as nightly summaries or bulk classification, these two settings together are often worth more than switching to a cheaper model.

Checking the estimate against reality

  1. Run a pilot of a few hundred real requests and read the token counts the API returns.
  2. Compare actual input and output averages with your estimate; output length is usually where estimates go wrong.
  3. Set a spending limit or alert in the provider's dashboard before launch.
  4. Review cost per request weekly for the first month, when usage patterns settle.

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

Questions people ask

Why are my real API costs higher than my estimate?
Usually because answers are longer than planned, prompts grow over time, or retries and hidden reasoning tokens were not counted. Compare the token counts the API reports with your assumptions.
How do I estimate LLM API costs?
Multiply input tokens per request by the input price per million, do the same for output tokens, add them, and multiply by requests per month.
How many tokens is 1,000 words?
For English text, roughly 1,333 tokens, since 1,000 tokens is about 750 words. Code and other languages usually need more.
What is the fastest way to cut an LLM bill?
Usually a cheaper model that still passes your tests, followed by shorter outputs and prompt caching for repeated input.
How much can caching and batch processing save?
In our example, caching 80% of each prompt and using batch processing cut a $200 monthly bill to about $64.

Sources

  1. Claude Platform Docs: Pricing
  2. OpenAI API pricing
  3. Gemini API pricing (Google AI for Developers)