Simulating production costs? Try our free browser-based TokenMeter Cost Calculator Open calculator →
Posts

How to Cut LLM API Costs

Practical ways to cut LLM API spend: prompt caching, model routing, output limits and batching, with the savings each lever delivers.
Onsp
Waterfall chart showing a $400 monthly LLM bill falling to $152 after prompt caching, model routing and capping output length

Most cost reductions come from three structural changes, not from prompt micro-tuning. Done in order, they typically remove half to two thirds of a bill without a measurable quality drop.

Step 1: Find where the money actually goes

Log cost per request alongside the feature, endpoint and user tier that produced it. In most applications a small share of requests dominates spend: long-context calls, agent loops that iterate, and retries. Optimising a high-volume cheap endpoint feels productive and moves the total by almost nothing.

Step 2: Route by difficulty

Send every request to the cheapest model that reliably passes evaluation for that task class, and reserve the flagship model for requests that genuinely need it. The spread makes this worthwhile: $0.10 on GPT-6 Luna against $10.00 on Claude Fable 5.1, a 100x difference on input.

A router needs a cheap classifier — a few hundred input tokens on a small model — and a fallback path when the small model's confidence is low. Start with two tiers, not five. Measure accepted-output rate per tier before widening the split.

Step 3: Cache the stable prefix

Move instructions, schemas and reference documents to the front of the prompt and keep them byte-identical across requests. Cache reads run 98% below fresh input on the best model in this dataset, and around 90% on the major providers.

The write premium matters: only cache prefixes that will be reused. A prefix used once costs more with caching than without.

Step 4: Truncate before you pay

Conversation history and retrieved context are usually the largest input line items, and both accumulate silently. Cap history at the last N turns with a rolling summary, and cut retrieved chunks below the relevance threshold rather than always sending the top ten. Halving retrieved context halves that part of the input bill with no change to the prompt logic.

Step 5: Use batch where latency does not matter

Asynchronous work — nightly re-indexing, bulk classification, backfills — belongs on a batch endpoint where one exists. Interactive and batch workloads should not share a code path, because the batch discount is forfeited the moment a request must return quickly.

Step 6: Guard the gains

Savings decay. Set a per-feature monthly budget, alert on week-over-week growth above a threshold, cap max output tokens per endpoint, and review prompt changes like production code. The most common cause of a cost regression is an innocuous prompt edit that doubles input length.

What this looks like in practice

Routing typically contributes the largest single reduction, caching the second, and truncation the third, with batch depending entirely on workload shape. The order matters less than doing all of them and then measuring. Model your expected saving in the calculator first, and compare it to the invoice after a month.

Related reading

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.