I started my career in finance before I moved into engineering, and the question I ask first about any AI feature is not “which model?” It is “what does one request cost, and how many will each customer make?” Teams that skip it find out from their first big invoice.

The good news is that the maths is simple, and you can do it before writing a line of code.

The formula

Every request to a language model is billed by tokens, roughly three quarters of a word each. Input tokens (what you send) and output tokens (what comes back) have different prices, and output is usually several times more expensive.

cost per request =
    uncached input tokens  x input price
  + cached input tokens    x cache-read price
  + output tokens          x output price      (including reasoning tokens)
  + tool overhead and any per-call tool fees

cost per user per month = cost per request x requests per user per month

Then multiply by your users, and compare the result with what you charge or what the feature saves.

A worked example

Take a support assistant inside a SaaS product. Each request sends about 5,000 tokens of fixed instructions and help-centre content, plus about 800 tokens of the user’s question and recent context, and gets about 400 tokens back. Using Anthropic’s published prices in October 2026, per million tokens:

  • Claude Sonnet 5.5: $2 input, $10 output, $0.20 for cached input reads.
  • Claude Haiku 4.5: $1 input, $5 output, $0.10 for cached input reads.

Without caching, one Sonnet request costs about 1.56 cents. With the fixed 5,000 tokens cached, it drops to about 0.66 cents. On Haiku the same request costs about 0.78 cents uncached and 0.33 cents cached. One detail that catches people out: each model has a minimum prompt length for caching. For Haiku 4.5 it is 4,096 tokens, so a shorter fixed prompt would not be cached at all.

Now scale it: 1,000 active users making 40 requests a month is 40,000 requests.

  • Sonnet, no caching: about $624 a month.
  • Sonnet, with caching: about $264 a month.
  • Haiku, with caching: about $132 a month.

Same feature, nearly five times difference in cost, before you change anything users can see. These figures ignore the small cost of writing the cache in the first place, which applies once every few minutes of activity, so treat them as a close estimate rather than an invoice.

Where the estimates go wrong

  • Agent loops. An agent that thinks, calls a tool and thinks again might make six model calls for one user action. The cached Sonnet example above becomes roughly $1,600 a month. Count steps, not user clicks.
  • Retries and failures. Timeouts, malformed output and validation failures all trigger repeat calls. Budget 10 to 20% on top until you have real data.
  • Reasoning tokens. Models that think before answering bill that thinking as output, the expensive kind.
  • Growing context. Chat history grows with every turn. A conversation that starts at 1,000 tokens can be at 20,000 by the tenth message.
  • Tokenizers differ. The same text is a different number of tokens on different models. Anthropic’s own pricing page notes that its newer tokenizer produces about 30% more tokens than earlier versions. Always measure on the model you will actually use.

The levers that cut cost

  1. Prompt caching. Put the stable part of the prompt first and cache it. Cached reads are typically a tenth of the normal input price at Anthropic and OpenAI.
  2. Batch processing. Anything that does not need an instant answer, like nightly summaries, lead enrichment or document processing, can run through batch APIs at 50% off at Anthropic, OpenAI and Google.
  3. Model routing. Send easy requests to a small model and only escalate hard ones. Most traffic in most products is easy.
  4. Do it in code first. Validation, lookups and arithmetic do not need a model. My AI lead validator runs cheap code checks before the AI is ever called.
  5. Cap output. Ask for short, structured answers. Output tokens cost the most.
  6. Measure per feature. Give each feature or customer its own API key or workspace so the provider’s usage reports tell you exactly where the money goes.

Turn it into a business decision

Once you have cost per user per month, the decision is ordinary product economics. If a feature costs 25 cents per user per month and saves each customer an hour of work, ship it. If it costs $4 per user on a $15 plan, you need caching, a smaller model, usage limits or a higher tier before launch, not after.

I build these numbers into every AI product I scope, because the right architecture depends on them. If you have an AI feature planned and want the cost modelled before you commit, book a free 30-minute call.

Sources: Anthropic: pricing · Anthropic: prompt caching · Anthropic: usage and cost API · OpenAI: prompt caching · OpenAI: cost optimization · Google: Gemini API pricing