Dev tools

How to Reduce LLM Costs: Caching, Batching, Models

Practical ways to reduce LLM costs without hurting quality: prompt caching, batch APIs, smaller models, routing, shorter prompts and output limits.

By OmniAI Editorial · Nov 19, 2026 · 8 min read

If you want to reduce LLM costs, the good news is that most AI apps waste a lot of money in the same few places. They send the same long instructions with every request, use a top-tier model for simple jobs, let answers run longer than needed, and pay full price for work that could wait an hour. Fixing these usually cuts LLM API costs substantially, often without users noticing any drop in quality.

This guide walks through the techniques that make the biggest difference, roughly in the order you should try them: measuring first, then trimming tokens, caching, batching, choosing smaller models and routing between them. Exact prices and discounts change often, so check your provider's current pricing page as you go.

Start by Measuring Where the Money Goes

You can't cut what you can't see. Before changing anything, log for every request:

  • Which feature or endpoint made the call.
  • The model used.
  • Input tokens, output tokens and, for reasoning models, reasoning tokens.
  • The cost, calculated from the provider's price list.

Then sort by cost. In most apps, one or two features account for most of the spend, and that's where to focus. Our guide to LLM tokens explains how input and output tokens turn into your bill.

Cut Tokens You Don't Need

The simplest way to reduce LLM costs is to send and receive fewer tokens.

Shorten prompts

System prompts tend to grow over time as people add rules and examples. Review them regularly:

  • Remove instructions that no longer matter or repeat each other.
  • Keep only the examples that actually change results.
  • Don't paste whole documents when a few relevant passages will do. Retrieval that finds just the right passages is far cheaper than sending everything.
  • In chat apps, summarise long conversation history instead of resending every message.

Limit output length

Output tokens usually cost several times more than input tokens. Set a maximum output length for each request, and ask for short answers when you don't need long ones. For structured tasks, ask for compact data like a short JSON object instead of a paragraph of explanation.

Be careful with reasoning models

Reasoning models write long internal chains of thought, billed as output. They're worth it for hard problems and wasteful for easy ones. Use a normal model for simple tasks, and set a thinking budget or effort level where the API allows it. Our guide to reasoning models explains when the extra thinking pays off.

A long grey bar of blocks being trimmed by a pair of grey scissors, with one short trimmed piece falling away in orange.
Shorter prompts and capped answers are the cheapest savings: fewer tokens in, fewer tokens out.

Use Prompt Caching

Many requests start with the same long block of text: system instructions, tool definitions, a policy document or a product catalogue. Prompt caching lets the provider store that repeated beginning and charge much less when it's reused.

How it works in practice:

  • Put the fixed parts first and the changing parts (the user's message) last. Caching matches the start of the prompt.
  • Keep the fixed part identical, down to the spacing. A single changed character near the top can break the cache.
  • Check how your provider does it. Some cache automatically, others need you to mark which part to cache, and caches usually expire after a few minutes without use.

Discounts on cached input are often large, up to around 90% off at some providers, though some charge a little extra the first time a prompt is written to the cache. For apps with long, stable instructions, prompt caching is often the single biggest saving.

Cache whole responses too

If many users ask exactly the same thing, such as a product FAQ or a daily summary, store the answer and reuse it. A response cache can be a few lines of code:

import hashlib
import json

_cache: dict[str, str] = {}

def cached_call(model: str, prompt: str, call) -> str:
    """call(model, prompt) -> answer. Reuses answers for identical requests."""
    key = hashlib.sha256(json.dumps([model, prompt]).encode()).hexdigest()
    if key not in _cache:
        _cache[key] = call(model, prompt)
    return _cache[key]

In production, use a shared store such as Redis with an expiry time, and only cache answers that don't depend on the user or on fresh data.

Use the Batch API for Work That Can Wait

Not every request needs an answer in seconds. Nightly reports, document processing, data labelling and evaluation runs can wait minutes or hours.

Major providers offer a batch API for this: you upload many requests at once, and the results come back later, usually within a day, at a discount that is commonly around half the normal price. Some combine it with prompt caching for even bigger savings.

Good candidates for batching:

  • Tagging or classifying large sets of records.
  • Summarising or translating document archives.
  • Generating product descriptions in bulk.
  • Running test suites and evaluations.
Many small grey cards gathered into one grey box with a small clock on its side, and an orange tag on the box.
Batching groups requests that can wait and sends them together at a lower price.

Pick the Smallest Model That Works

Model choice is often the biggest lever of all. The difference in price between a provider's top model and its smallest model can be ten times or more.

For many tasks, such as classification, extraction, simple summaries or short replies, a small model does just as well as a large one. Our guide to LLM evaluation shows how to test this properly: run the same test set on a cheaper model and compare the scores before you switch.

Other options to consider:

  • Open-weight models you host yourself can be cheaper at high, steady volume, though you take on the work of running servers.
  • Fine-tuned small models can match large ones on one narrow task, at a fraction of the cost per request.

Route Requests Between Models

Model routing sends each request to the cheapest model that can handle it. Easy requests go to a small, fast model; hard ones go to a large model.

You can route in a few ways:

  • By feature: use a fixed model per task, such as a small model for tagging and a large one for complex analysis.
  • By rules: send short, simple requests to a small model and long or complex ones to a large one.
  • With a classifier: a small model or a lightweight classifier judges how hard each request is and picks the model.
  • With fallback: try the small model first, check the answer (for example, validate the format or a confidence signal), and escalate only if it fails.

Routing works best when you can measure quality, so you know the cheap path isn't quietly giving worse answers.

A grey fork in a path sending many small grey dots down a short branch to a small chip and a single orange dot down a longer branch to a large chip.
Model routing sends easy requests to a cheap model and saves the expensive one for the hard cases.

Other Ways to Reduce LLM Costs

  • Avoid retries that repeat everything. If a call fails, retry only what failed, and stop after a sensible limit.
  • Use structured output so you don't pay for retries caused by broken formats.
  • Stop runaway agents. Agents that loop can burn through tokens. Set limits on steps, tool calls and total tokens per task.
  • Set budgets and alerts on your provider account and per feature, so a bug can't run up a huge bill overnight.
  • Review spend monthly. Prices drop and new models appear regularly, so the best option this month may not be the best next month.

A Simple Plan to Reduce LLM Costs

  1. Log tokens and cost per feature for a week.
  2. Trim prompts and set output limits on the most expensive features.
  3. Reorder prompts so fixed text comes first, and turn on prompt caching.
  4. Move anything that can wait to the batch API.
  5. Test a smaller model on each feature with an evaluation set, and switch where quality holds.
  6. Add routing for features with a mix of easy and hard requests.
  7. Set budgets and alerts, and repeat the review regularly.

FAQ

How can I reduce LLM API costs?

Measure where the money goes, then shorten prompts, cap output length, use prompt caching for repeated instructions, send non-urgent work through a batch API, and switch simple tasks to smaller models. Routing between small and large models can save more on mixed workloads.

What is prompt caching?

Prompt caching lets an AI provider reuse the beginning of a prompt that you send repeatedly, such as long system instructions, and charge much less for it. To benefit, put fixed content first and keep it identical between requests.

How much does a batch API save?

Batch APIs from major providers commonly cost around half the normal price, in exchange for results that arrive later, usually within a day. Check your provider's current pricing for exact terms.

Is a smaller model good enough?

Often, yes, for focused tasks like classification, extraction and short summaries. Test the smaller model on a set of real examples and compare its scores with the larger model before switching.

What is model routing?

Model routing sends each request to the cheapest model likely to handle it well. Easy requests go to a small model and difficult ones to a larger model, which lowers costs while keeping quality where it matters.

All articles

Read next

Language

EnglishEnglish · en TürkçeTurkish · tr DeutschGerman · de العربيةArabic · ar

Account

Enter your email. We’ll send you a sign-in link and a 6-digit code. No password needed.

Sign in

Theme

Language

Show our email address

To keep spam out of our inbox, please confirm your own email first. We will send you a 6-digit code.

We send codes only to these providers: gmail.com, googlemail.com, outlook.com, hotmail.com, live.com, msn.com, proton.me, protonmail.com, pm.me, icloud.com, me.com, mac.com, yahoo.com, aol.com, gmx.de, gmx.net, web.de, t-online.de, yandex.com, omniai.blog