Skip to content

AI · 10 min read

How to Reduce LLM and AI Agent Costs: 10 Levers That Work in Production

Ten practical ways to cut LLM and AI agent running costs: measurement, prompt caching, model routing, less context, batch APIs, output caps and budgets.

Zain Khalid MalikZain Khalid MalikCTO & Co-founder, Innovation InsightPublished
Laptop on a glass desk showing a dashboard of charts and usage figures

Short answer

Most LLM bills can shrink by half or more without a visible drop in quality. Measure tokens and cost per request first, then turn on prompt caching, route easy requests to a small model, trim the context and tool list sent on every call, batch anything a person is not waiting for, cap output length and set per-user budgets. In our worked example, caching and routing take a support chatbot from $570 to $80 a month in model cost.

Where the money goes

An LLM bill is input tokens plus output tokens, multiplied by the price of the model, multiplied by how many calls you make. Agents make the last factor large: a single support conversation or agent task is several model calls, and every call resends the system prompt, the tool definitions, the conversation so far and any retrieved documents. That repeated input is usually most of the bill, which is why the biggest savings come from sending less, sending it to a cheaper model, or paying less for the parts that repeat.

The figures in this post use the same model prices and workload assumptions as our AI agent cost calculator, checked on 9 October 2026 against the vendors' pricing pages. The example is a web support chatbot: 6 model calls per conversation, about 3,500 input and 250 output tokens per call, 10,000 conversations a month.

SetupModel cost per month (mid-point)Saving vs first row
Claude Sonnet 5.5, no caching$570—
Claude Sonnet 5.5, prompt caching on$33142 percent
Routing: 80% Claude Haiku 5.5, 20% Sonnet 5.5, caching on$8086 percent
Claude Haiku 5.5 only, caching on$1797 percent

The last row is cheapest, but only acceptable if the small model answers well enough on your own test set. Routing is the usual compromise: the cheap model handles the routine questions and hands over the rest.

1. Measure before you optimise

Log, for every model call, the model, input tokens, cached input tokens, output tokens, latency, the feature or agent step that made the call, and the user or tenant. With that one table you can answer which feature costs the most, which users are outliers and whether a change helped. Without it, cost work is guesswork. Most model APIs return token counts in the response, so this is a few lines of code at the place where you call the model.

2. Turn on prompt caching

Prompt caching bills the repeated start of a prompt (system prompt, tool definitions, long documents, earlier turns) at a cache-read rate instead of the full input price. In our price table that rate is $0.10 per million tokens on Claude Sonnet 5.5 against $2 for normal input, and about one tenth of the input price on OpenAI and Gemini models. To benefit, put the stable content first and the changing content last, and keep the stable part byte-for-byte identical between calls.

3. Route requests to the smallest model that works

Prices differ by an order of magnitude or more between tiers. Per million tokens: Claude Haiku 5.5 $0.10 in / $0.50 out, Claude Sonnet 5.5 $2 in / $10 out, GPT-5.4 mini $0.75 in / $4.5 out, GPT-5.4 $2.5 in / $15 out, Gemini 3.5 Flash-Lite $0.30 in / $2.5 out. A router can be as simple as a rule (short questions, known intents and classification go to the small model) or a small model that decides whether to escalate. Measure both quality and cost on a fixed evaluation set before and after.

4. Send less context on every call

  • Trim the system prompt. Long lists of rules that rarely apply belong in retrieval or in an Agent Skill that loads only when needed.
  • Send only the tools the current step can use. Twenty tool definitions on every call are thousands of tokens.
  • Cap retrieved chunks. Retrieving ten chunks when three answer the question triples that part of the input.
  • Summarise or drop old turns in long conversations instead of resending the whole history.
  • Strip HTML, boilerplate and duplicate text from documents before they reach the model.

5. Use batch APIs for anything nobody is waiting for

OpenAI, Anthropic and Google all take 50 percent off requests sent through their batch endpoints, with results returned within hours. Document extraction, nightly classification, re-indexing and offline evaluation all qualify. In the calculator, extracting 50,000 documents a month on Claude Sonnet 5.5 drops from between $1,469 and $2,203 to between $734 and $1,102 in model cost when batched. Live chat, phone calls and agents a person is watching cannot use it.

6. Limit output length

Output tokens cost several times more than input tokens on every model in our table. Set a maximum output length per feature, ask for structured output (a JSON object with the fields you need) instead of prose where a program reads the result, and tell the model the length you want.

7. Cut agent steps

An agent that takes eight steps to do a four-step job pays twice. Give tools clear names and descriptions so the model picks the right one first time, return compact tool results rather than whole API responses, and move fixed sequences (always fetch the order, then the customer) into one tool or plain code. Cap the number of steps per task and stop with a clear message when the cap is reached.

8. Cache answers, not only prompts

Many questions repeat: opening hours, refund policy, the same product question asked a hundred ways. An exact-match or semantic cache in front of the model serves those without a model call. Expire cached answers when the underlying content changes, and do not cache anything personal.

9. Set budgets and rate limits

Put a per-user and per-tenant daily token budget in code, a spending cap in each vendor's console, and an alert when spend per hour jumps. These stop a bug, a loop or an abusive user from turning into a large invoice before anyone notices.

10. Protect quality while you cut

Every lever above can quietly make answers worse. Keep an evaluation set of real questions with known good answers, run it before and after each change, and track the result next to cost. A cheaper agent that answers fewer questions correctly is not cheaper once support tickets and refunds are counted. Our guide on why AI agent projects fail covers evaluation in more depth.

A one-week cost review

When a client asks us why an AI feature costs what it does, we run the same short review. It usually finds most of the saving in the first two days.

  1. Day 1: add per-call logging if it is missing and collect a few days of real traffic. Rank features and agent steps by total cost.
  2. Day 2: read the ten most expensive requests in full. Look for repeated context, unused tool definitions, oversized retrieval and long outputs nobody reads.
  3. Day 3: restructure prompts for caching, trim the tool list per step and cap retrieval and history. Re-run the evaluation set.
  4. Day 4: try the next smaller model on the routine share of traffic behind a flag. Compare quality and cost on the same evaluation set.
  5. Day 5: move offline work to batch endpoints, add budgets and alerts, and write down the new cost per request so it can be watched.

Where caching and routing do not help

  • Prompts that change from the first token, such as one-off document analysis with no shared instructions. Put any fixed instructions first anyway; the rest cannot be cached.
  • Very low volume. If the model bill is a few dollars a month, engineering time on optimisation costs more than it saves; fixed infrastructure is the bigger line.
  • Tasks where only the largest model is accurate enough. Then the saving comes from fewer steps and shorter context, not a cheaper model.
  • Latency-critical voice agents, where a router adds a step to every turn. Route per call rather than per turn, or pick one model that is fast and good enough.

Infrastructure is part of the bill too

Model cost is not the whole running cost. Hosting, a vector database for retrieval, logging and evaluation add a fixed monthly amount that matters at low volume. The AI agent cost calculator shows both, and our post on what it costs to run an app covers the non-AI side.

Getting help

We audit AI features for cost and quality and apply the changes above in production: logging, caching, routing, evaluation sets and budgets. Most of this work fits in a short engagement priced like an AI feature ($8k to $60k depending on scope). If you build on Claude, see our Claude development page; for agents end to end, AI agent development.

Sources

Need a number for your project?

Send a short brief and get a written estimate.

A senior engineer replies within one business day. No sales call required.

Zain Khalid Malik, CTO & Co-founder, Innovation Insight

Zain Khalid Malik

CTO & Co-founder, Innovation Insight

Zain owns architecture, engineering standards and the platform team at Innovation Insight. He sets the bar for code quality, security and the tooling every squad ships with.

LinkedIn
FAQ

Related questions.

What is the fastest way to reduce LLM costs?

Turn on prompt caching and move the stable part of the prompt to the start. It needs no change in behaviour and bills the repeated input at a fraction of the normal price. Routing easy requests to a smaller model is usually the next biggest saving.

Does prompt caching change the answers?

No. Caching only changes how the repeated part of the prompt is billed and how quickly it is processed. The model sees the same prompt either way.

Is a smaller model good enough?

Often for routine requests, not always for hard ones. Test it on an evaluation set of your own real questions, and route only the cases it handles well. Escalate the rest to a larger model.

When can I use a batch API?

For work nobody is waiting on: document extraction, nightly classification, re-indexing and offline evaluation. All three major vendors give a 50 percent discount for batch requests, with results returned within hours.

How do I stop one user running up a huge bill?

Set per-user and per-tenant daily token budgets in your code, a hard spending cap in each vendor's console and an alert on sudden spikes. Cap the number of steps an agent may take per task.