Most AI bills I audit are not high because AI is expensive. They are high because nobody put a limit on them, the same prompt is paid for in full thousands of times a day, and every request goes to the most expensive model because nobody tested a cheaper one.
This guide ranks ten ways to cut LLM API costs by how much they usually save, how hard they are, and when they backfire. Prices and discounts below were checked on the providers’ own pages in December 2026. They change often, so check again before you plan around them.
The short answer
| Method | Typical saving | Effort | Watch out for |
|---|---|---|---|
| 1. Budgets per user and per day | Stops runaway bills | Low | Set limits from real usage, not guesses |
| 2. Prompt caching | 75 to 95% off repeated input | Low | Only works if the prompt start is identical |
| 3. Batch processing | About 50% off | Low to medium | Results can take up to 24 hours |
| 4. Cheaper model per task, tested | Often 60 to 90% on that task | Medium | Quality drops you did not measure |
| 5. Response caching | Up to 100% on repeat questions | Low | Never share one user’s answer with another |
| 6. Shorter prompts and capped output | 20 to 60% | Low | Removing context the model needed |
| 7. Stop loops and retries | Varies, can be most of a bad month | Low | Agents that retry the same failing call |
| 8. Control reasoning and thinking tokens | Often large on reasoning models | Low | Hidden tokens billed as output |
| 9. Open-source or self-hosted models | Large at steady high volume | High | Idle hardware at low volume |
| 10. Measure cost per feature | Finds which of 1 to 9 matters | Low | Trackers that miss cached or thinking tokens |
If you only do two things this week, do 1 and 2.
1. Put a hard budget on every user and every day
Providers bill after the fact. Your monthly limit in the provider dashboard is a blunt instrument: when it trips, every customer loses the feature at once. A budget in your own code can be per user, per feature and per day, and it can fail softly, for example by switching to a cheaper model or a canned answer.
The important detail is to reserve budget before the call, not after. If you only add up costs after each response, ten parallel requests from the same user can all pass the check and overspend together.
llm-cost-shield does this in JavaScript and Python: it reserves the estimated cost before each call, settles the real cost after, and blocks or downgrades when a user or day runs out.
2. Turn on prompt caching, and order your prompt for it
Every provider now discounts input tokens it has seen recently, as long as the start of the prompt is identical:
- OpenAI applies caching automatically on recent models. On its December 2026 price list, cached input on the newest models costs 5 to 10% of the normal input price.
- Anthropic charges cache reads at about 0.1 times the input price on most models. Writing to the cache costs 1.25 times the input price for the 5-minute cache and 2 times for the 1-hour cache, so a prefix you write often and read rarely costs more than no cache at all.
- Google Gemini caches implicitly on Gemini 2.5 and newer models, with a 90% discount on cached tokens on Google Cloud, and offers explicit caching with a guaranteed discount on models that support it.
The practical rule is the same everywhere: put the fixed part first (system instructions, tool definitions, policies, product catalog extracts) and the changing part last (the user’s message). A timestamp or user name near the top of the prompt breaks the cache on every call.
3. Use batch pricing for anything that can wait
OpenAI, Anthropic and Google all offer batch processing at roughly half the normal price, in exchange for results within up to 24 hours. In a store, that covers more work than people expect: rewriting product descriptions, tagging reviews, translating a catalog, generating alt text, nightly summaries and model evaluations.
OpenAI also offered a “flex” tier at batch prices for normal requests, but it is being wound down on its newest models, so do not build new work on it.
green-batch-ai writes the batch files for all three providers and, for jobs you run on your own hardware, picks the hour when the grid is cleanest.
4. Use the cheapest model that is good enough, per task, with proof
This is usually the biggest single saving, and the one most often done badly. “We switched to the mini model and nobody complained” is not a test. Neither is trying five examples by hand.
The method that holds up:
- Collect 100 to 300 real examples for one task, with the answer you consider correct.
- Run them through your current model and one or two cheaper ones.
- Grade the answers the same way for every model (exact match, a rule, or an LLM judge against the reference answer).
- Switch only if the cheaper model is statistically no worse by a margin you choose in advance.
right-size-model runs exactly this, with a paired non-inferiority test, and prints the monthly saving, energy and CO2 for each switch. In my audits, classification, extraction, routing and short customer replies are the tasks that move to small models most often. Long multi-step reasoning rarely does.
5. Cache whole responses for repeated questions
Prompt caching discounts the input. A response cache skips the call entirely. “What is your return policy?” asked a thousand times a day should cost one call, not a thousand.
Two rules keep this safe. Cache per user by default, so one customer never receives an answer generated for another. And only share answers globally when they are the same for everyone, such as FAQ replies. llm-cost-shield’s cache follows both rules.
6. Shorten prompts and cap the output
Prompts grow by accretion: a rule added after each incident, examples nobody removed, a full policy pasted where one paragraph would do. In the case study where I cut a client’s AI API costs by 62% in 10 days, the average prompt went from 1,800 tokens to 600 with the same outputs.
Also set a maximum output length on every call. Output tokens cost several times more than input on most models, and a model that rambles on one request in a hundred still sets your worst-case bill.
7. Stop loops and blind retries
Agents fail in loops: a tool returns an error, the agent tries again with the same arguments, forever. Retry logic without a limit does the same thing. One stuck process can spend more in a night than your real users spend in a week.
Limit retries, detect identical repeated calls within a short window, and stop the run when it trips. The llm-cost-shield analyzer flags repeated requests within a minute and users spending over 20 times the median, which is where loops and abuse show up first.
8. Watch reasoning and thinking tokens
Reasoning models think before they answer, and those hidden tokens are billed as output. On Gemini they are reported in a separate field from the visible answer, so a cost tracker that reads only the answer’s token count can miss most of the bill. On OpenAI they are counted inside the output tokens.
Set the reasoning effort or thinking budget per task. A product-tag classifier does not need deep reasoning; a refund decision might.
9. Move steady, high-volume work to open models
Self-hosted or open-weight models pay off when the workload is steady and large enough to keep the hardware busy, the task is narrow enough that a fine-tuned smaller model matches the large one, and someone can run and monitor it. That is the engagement where my clients have seen the largest drops, but it is the last step, not the first. At low or spiky volume, a cheap API model is usually cheaper than idle hardware.
If you serve smaller models on CPUs, how you set threads, worker processes and batching matters more than people think. In one XGBoost test on 2 vCPUs, two processes with one thread each served 1.8 times more rows per second than one process with two threads, at 44% less energy per row. parallel-inference-tuner finds that setting for your own model and machine.
10. Measure cost per feature before you change anything
Every method above works better when you know which feature and which users drive the bill. Log, for every call: feature name, user ID, model, input, cached, cache-write, output and reasoning tokens, and the cost. Then rank features by spend.
A surprising number of trackers get the bill wrong. Common misses are thinking tokens, the two different Anthropic cache-write prices, and long-context surcharges above a prompt size. llm-cost-shield’s analyzer handles all three and works on logs you already have.
A sensible order of work
- This week: budgets per user and per day, output caps, and prompt order for caching.
- Next: response caching for repeat questions, and batch pricing for anything that can wait.
- Then: test cheaper models task by task, and keep only the switches that pass.
- Only at steady high volume: open or self-hosted models.
Why this is also the green choice
Every cached answer, avoided loop and request moved to a smaller model is computation that never runs, and so electricity that is never used. Cost and energy fall together. My research is on exactly this side of machine learning, the cost and energy of each prediction in production, and the tools linked above come out of that work.
If you would like the audit done for you, with the findings fixed and the savings measured, book a free call. If you would rather do it yourself, every tool above is free and open source.
Sources
- OpenAI API pricing, prompt caching and flex processing documentation (developers.openai.com), checked December 2026.
- Anthropic prompt caching pricing, as implemented and tested in llm-cost-shield.
- Google Cloud Vertex AI context caching overview and Gemini API caching documentation, checked December 2026.
- Batch limits and discounts for OpenAI, Anthropic and Gemini, as documented in green-batch-ai.