Guide · LLM cost

How to reduce LLM costs: six levers, one number to watch.

Every LLM bill is calls × tokens × price. Each lever below cuts one of those three — and cost per completed task tells you whether it worked.

Providers now discount repeated prompt prefixes and work that can wait, smaller models handle most routine steps, and most prompts carry tokens nobody needs. This guide shows how to measure first, which lever cuts which part of the bill, what each one saves according to the providers’ own documentation, and the order to apply them.

Updated · 11 sources

Cost per taskcalls × (tokens in × price in + tokens out × price out)
Prompt cachingcuts the price of the repeated input prefix
Batch APIshalves the price of work that can wait a day
Model routingsends routine steps to a cheaper model
Prompt trimmingcuts the tokens you send
Output controlcuts the tokens you ask for
Response cachingremoves repeat calls entirely

How to reduce LLM costs without losing quality?

To reduce LLM costs, first measure cost per completed task, then cut the three factors of the bill: the price per token (prompt caching, batch APIs), the tokens per call (trimmed prompts, retrieved context that fits, shorter outputs) and the number of calls (response caching, routing routine steps to smaller models, fewer retries). Knowing how to reduce LLM costs safely means re-running an evaluation set after each change, so savings never come from worse answers.

Step zero

Measure LLM cost per task before you cut anything.

Cost per token is the provider’s unit. Cost per completed task — an invoice processed, a ticket answered — is yours. A cheaper model that needs two retries and a longer prompt can cost more per task than the expensive one.

  1. Tag every call

    Team, application, feature and run on each model call — at the gateway, so nothing is missed.

    attribution
  2. Count four numbers

    Input tokens, cached input tokens, output tokens and calls per task.

    usage
  3. Price once

    One price table applied to every call, including reasoning tokens.

    price table
  4. Count failures

    Retries, refusals and abandoned runs cost money and finish nothing.

    waste
  5. Divide by outcomes

    Spend over tasks completed gives cost per task.

    unit cost
  6. Pair with quality

    Keep an evaluation score next to the cost, so a cut that hurts answers shows up.

    evals
Worked example — our arithmetic at illustrative prices ($2.50 / M input, $10 / M output tokens)
A support assistant answers one ticket in 3 model calls.
Each call sends 12,000 input tokens and gets 600 back.

Input:  3 × 12,000 = 36,000 tokens × $2.50/M = $0.090
Output: 3 ×    600 =  1,800 tokens × $10.00/M = $0.018
Cost per ticket                                = $0.108

If 10,000 of each prompt is a fixed instruction block
that a provider caches at 0.1× the input price:
Cached:  3 × 10,000 × $0.25/M = $0.0075
Fresh:   3 ×  2,000 × $2.50/M = $0.0150
Output (unchanged)            = $0.0180
Cost per ticket               = $0.0405   (−62.5%)
(ignoring the one-off cache write)
Price per token

How to reduce LLM costs with caching: discount the repeated prefix, or skip the call.

Two different things share the word “cache”. Prompt caching is done by the provider and lowers the price of a repeated prefix; the model still writes a fresh answer. Response caching is done by you or your gateway and skips the call altogether.

at the provider

Prompt (prefix) caching

The provider reuses its work on an identical prompt prefix — instructions, tool definitions, a long document — and bills those tokens at a discount.

  • A fresh answer every time
  • Needs an exact, unchanged prefix
  • Automatic on supported OpenAI and Gemini models; on Anthropic’s API, one cache_control field in the request turns it on
  • Short lifetime: minutes to hours
at your gateway

Response caching

A stored answer is returned for a repeated request. A semantic cache also matches prompts that are close in meaning.

  • No model call at all
  • Exact match, or similar enough by embedding
  • Risk: a near-match may need a different answer
  • Best for FAQ-style, read-only questions
Input token priceWhat it savesThe whole call
None: Anthropic’s docs say the response is identical to an uncached oneEffect on answersReturns an earlier answer
Anything changing early in the promptWhat breaks itQuestions that look alike but differ
Order of the promptWhere to set it upGateway or application
95%
the most OpenAI discounts input tokens that hit its prompt cache
OpenAI prompt caching guide
0.1×
Anthropic’s standard price for cache reads, against the base input price (some newer models are lower); a 5-minute cache write costs 1.25×, a 1-hour write 2×
Anthropic prompt caching docs
On
Gemini’s implicit caching is enabled by default for Gemini 2.5 and newer models
Google Gemini API: context caching

Order the prompt for the cache. Caches match from the start of the prompt. Put stable instructions, tool definitions and shared reference material first, and the user’s question, timestamps and per-user details last. A date stamped at the top of the system prompt makes every call a miss.

Price per token

Batch APIs: half price at OpenAI, Anthropic and Azure for work that can wait.

Classifying a backlog, re-extracting fields from last year’s documents, running an evaluation set: none of it needs an answer in two seconds. The providers below sell the same tokens at half price when you submit them as a batch.

50%
OpenAI Batch API discount against synchronous calls; each batch completes within 24 hours
OpenAI Batch API guide
50%
Anthropic Message Batches discount; most batches finish in under an hour, and the discount stacks with prompt caching
Anthropic batch processing docs
50%
Azure OpenAI global batch, against global standard, with a 24-hour target turnaround and a separate enqueued-token quota
Microsoft Learn: Azure OpenAI batch

Send as a batch

  • BackfillsRe-processing documents after a schema change.
  • EvaluationsScoring a golden dataset against a new model or prompt.
  • Nightly enrichmentSummaries, tags and embeddings for yesterday’s records.

Keep synchronous

  • ConversationA person is waiting for the reply.
  • Agent loopsEach step needs the last step’s result.
  • ApprovalsA reviewer is holding the document open.

Batches have their own quota. OpenAI and Azure both keep batch tokens apart from your real-time rate limits, so moving bulk work to a batch also frees capacity for the people using your assistants.

Calls and price

Model routing: small models for frequent routine steps, large ones for hard steps.

Most agent runs mix hard steps with routine ones — classify, extract a date, format the reply. Sending every step to the largest reasoning model pays top price for work a smaller model can often do as well — which your evaluation set confirms or refutes.

Hard step
Rare and hardContract analysis, a multi-document answer. Use the strongest model; volume is too low for savings elsewhere to matter.Large model
Frequent and hardTry a cascade: a small model answers first and passes to a large one when its confidence or a check fails.Cascade
Routine step
Rare and routineAny capable model works. Do not spend engineering time here.Default model
Frequent and routineClassification, extraction, formatting. A small model — or a fine-tuned small one — at a fraction of the price.Small model
Low volumeHigh volume
98%
the most cost FrugalGPT’s learned cascade saved while matching the best single model (GPT-4) on the authors’ test sets (Stanford, 2023)
Chen, Zaharia, Zou: FrugalGPT
2×+
cost reduction “in certain cases” without losing response quality, using learned routers between one strong and one weak model on public benchmarks
Ong et al.: RouteLLM (2024)

Prove the switch with evaluations. Research results are averages on public benchmarks. Before moving a step to a smaller model, run your own evaluation set on both and compare the score and the cost per task side by side.

Tokens per call

Trim the tokens you send and the tokens you ask for.

Every token sent is paid for on every call, and prompts grow by accretion over months of edits. Input and output both reward a regular audit.

Token audit for one prompt
  • Retrieve fewer, better passagesRe-rank search results and send the best few rather than every hit.
  • Summarize long conversationsReplace old turns with a running summary once a thread grows.
  • Send only the tools a step needsEvery tool definition is input tokens on every call.
  • Cut duplicated instructionsPrompts collect repeated rules and examples over months of edits.
  • Ask for structured outputA schema with short field names beats a paragraph that is parsed later.
  • Set an output budgetSet the maximum output tokens and reasoning effort per step, so a classifier cannot write an essay.
  • Compress what must stayPrompt compression research such as LLMLingua reports up to 20× compression with little loss on its benchmarks.
  • Stop retry stormsClient libraries retry on their own (OpenAI’s Python library twice by default). Give each fault one retry owner that honours the provider’s Retry-After; stacked retries multiply spend.
Sequence

How to reduce LLM costs in order: least change first.

Start with the levers that change nothing about your answers, then move to the ones that need an evaluation run to prove them.

No change to answersNeeds proof by evaluation
12345678
  1. Measure cost per taskWithout it, every later saving is a guess.
  2. Reorder prompts for the cacheStable content first; the provider does the rest.
  3. Batch what can waitHalf price for backfills and evaluations.
  4. Fix retriesOne owner per fault; fewer wasted calls.
  5. Trim prompts and outputsFewer tokens; check answers still hold.
  6. Route routine stepsSmaller models where evaluations allow.
  7. Semantic response cacheSkip calls for near-duplicate questions.
  8. Fine-tune a small modelFor high-volume, narrow tasks with stable labels.
On Botminds

LLM cost on Botminds: allowances checked before the run, cost by team after it.

On Botminds every agent reaches its model through one built-in LLM gateway. The gateway checks the allowance, applies the agent’s model choice, paces calls and prices every token — so each lever above has one place to live.

The cost loop on the platform
  1. Allowance before the runChecked at the one door every run passes — chat, workflow step, schedule or API call.
  2. A model per agentA model is a record; moving an agent or a whole project to a cheaper model is one edit, and moving back is another.
  3. Proven by evaluationsProve each agent’s model choice with evaluations, so a cheaper model has to earn its place.
  4. Cache-friendly callsAgents on gateway models send a stable cache key, so providers that cache serve repeated instructions at a lower price.
  5. Paced to each quotaCalls are paced to each deployment’s declared quota; every retry is counted, so a pattern shows up.
  6. Cost by teamEvery call carries its workspace and project and is priced from one table — per run, agent, project and workspace.

Spend by team and per agent shows where the next model choice should change.

Read the full design in the LLM gateway, and how models are set per agent in the Academy lesson LLMs and services.

Questions people ask

How to reduce LLM costs: common questions.

The technology behind itLLM gatewayEvery model, with fallback and cost by team
How to reduce LLM costs quickly?

The fastest ways to reduce LLM costs: order prompts so stable content comes first (prompt caching), send work that can wait through a batch API at half price, and stop stacked retries. None of these change your answers. Then trim prompts and route routine steps to smaller models, checking quality with an evaluation set.

How do I reduce LLM token usage?

Send fewer, re-ranked passages instead of every search hit, summarize long conversation history, include only the tool definitions a step needs, ask for structured output and set a maximum number of output tokens per step.

What is prompt caching?

Prompt caching lets a provider reuse its work on an identical prompt prefix — system instructions, tool definitions or a long document — and bill those input tokens at a discount. The model still writes a fresh answer. OpenAI and Gemini apply it automatically on supported models; on Anthropic’s API the caller adds a cache_control field to the request.

What is the difference between prompt caching and semantic caching?

Prompt caching discounts a repeated prefix at the provider; the model still answers. Semantic caching, usually in a gateway, returns an earlier stored answer when a new prompt is close enough in meaning, skipping the call — cheaper still, but a near-match can need a different answer.

How much does a batch API save?

OpenAI, Anthropic and Azure OpenAI each price batch work at half the synchronous rate, in exchange for results within 24 hours (a target, on Azure). Anthropic notes most batches finish within an hour and that the batch discount stacks with prompt caching.

What is LLM cost per task?

Total model spend divided by the tasks completed — tickets answered, documents processed. It counts every call, retry and failed run, so it shows the real price of an outcome where cost per token does not.

Is a smaller model always cheaper?

Per token, yes; per task, not always. A smaller model that needs longer prompts, more calls or more retries — or whose errors a person must fix — can cost more per completed task. Compare both on your own evaluation set.

How does Botminds help control LLM costs?

Botminds checks allowances before a run starts, prices every call from one table and shows cost per run, agent, project and workspace. Models are set per agent, proven by evaluations, and agents send a stable prompt cache key. See the LLM gateway.

See it on
your own work.

Bring one process and its documents. We’ll show you the agents, the controls and the record, running on your data.