Debuly

Guide · Developer platforms

How to reduce your LLM API costs

Cut LLM API spend with measurement, caching, model routing, batching and budget caps: the steps, seven tools compared with pricing and stated limits, and mistakes.

By the end of this guide you will know where your LLM API spend goes, have cut it with a short list of changes (shorter prompts, caching, cheaper models for easy requests, batching), and have put budget limits in place so a bug cannot run up a surprise bill. The work is done by a mix of tools: a cost calculator or tracker to measure, and an AI gateway or provider features to enforce savings.

If you want to reduce LLM API costs, the order matters: measure first, change the biggest cost driver, then check that quality has not dropped. This guide covers each step and compares seven tools from our Developer platforms category.

Key takeaways

  • Measure cost per feature and per user first. Most spend sits in a few prompts, so fix those before anything else.
  • The main levers are shorter prompts and outputs, caching, sending easy requests to cheaper models, and batching work that can wait.
  • A gateway or router (LiteLLM, Portkey, FastRouter.ai, Orq.ai) adds routing, fallbacks and budgets in one place, and Portkey, FastRouter.ai and Orq.ai also list caching, but some of these features sit on paid plans.
  • Every saving needs a quality check. A cheaper answer that is wrong costs more than it saves.

What you need before you start

  • Your current usage data. Provider invoices or usage dashboards, ideally split by feature, customer or API key.
  • A list of your LLM calls. Which prompts run, how often, with which model, and how long the inputs and outputs are.
  • A quality test set. A set of real prompts with expected answers, so you can confirm that savings do not hurt results. See how to evaluate LLM outputs before you ship.
  • Access to the code or gateway config. Most savings need a code or configuration change.
  • Time. A first measurement and the quickest wins take under a day. Routing and gateway changes take longer.
  • Difficulty. Moderate. You need to be comfortable changing application code.

Which kind of AI tool fits this job

Match the tool to the part of the problem you are solving.

Estimating before you build. The Mydentify AI Model Cost Calculator is a free web calculator. You enter requests per month, input and output tokens and the cached share of input, and it compares estimated monthly bills across models. Its prices refresh from the OpenRouter public catalog, and it states that estimates exclude discounts, taxes, free tiers and retries.

Tracking real spend. BurnRate combines OpenAI and Anthropic spend in one dashboard with workspace budgets, and has a local CLI for coding-tool sessions. Its budgets do not block provider spending, so treat them as visibility, not enforcement.

Provider features that cut cost directly. Claude Platform lists prompt caching with separate cache write and hit rates, and batch processing at 50% less than standard API calls. Other providers have similar features, so check your own provider's pricing page.

A gateway that enforces savings centrally. LiteLLM is an open-source gateway and Python SDK with virtual keys, budgets, rate limits, fallbacks and a cost figure for every call. Portkey adds simple and semantic caching, virtual keys with budgets, and observability. FastRouter.ai offers an auto-router that picks models by cost, latency or quality, response caching, budget caps and a weekly Insights report. Orq.ai lists a Smart Router that can send simple prompts to cheaper models, caching and budgets.

Step 1: Measure where the money goes

You cannot cut what you cannot see.

  1. Export a month of usage from your provider, split by model and API key if you can.
  2. Tag requests by feature, customer or environment. Gateways such as LiteLLM and Orq.ai record each request with its cost.
  3. Find the top three prompts by total spend, which is price per call multiplied by call volume.
  4. Note average input and output length for each, since output tokens usually cost more per token than input.

Check it worked by being able to say which three features cause most of your bill.

Step 2: Model the savings before you change anything

A quick estimate stops you from optimising the wrong thing.

  1. Enter your real volumes into a calculator. The Mydentify calculator asks for requests per month, input tokens, output tokens and cached input percentage.
  2. Compare your current model with cheaper candidates on the same workload.
  3. Remember what the estimate leaves out: retries, tool charges, discounts, taxes and free tiers.
  4. Remember that a cheaper model is not automatically a better fit for quality, latency or reliability.

Check it worked by having a rough monthly figure for each option to compare with your actual bill.

Step 3: Shorten prompts and cap outputs

The cheapest token is the one you never send.

  1. Remove repeated instructions, long examples and unused context from prompts.
  2. Send only the retrieved passages that are relevant, rather than whole documents.
  3. Set a maximum output length and ask for concise formats such as short JSON.
  4. Trim conversation history by summarising older turns.
  5. Re-run your test set after each change to confirm quality holds.

Check it worked by seeing average tokens per request fall while test scores stay level.

Step 4: Turn on caching

Repeated work should be paid for once.

  1. Use prompt caching for long, stable prefixes such as system prompts and reference documents. Claude Platform lists prompt caching with separate cache write and hit rates.
  2. Use response caching for identical repeated requests. FastRouter.ai, Portkey and Orq.ai list caching, and Portkey lists semantic caching as well as simple caching.
  3. Put stable content first and variable content last in your prompts, so the cacheable prefix is as long as possible.
  4. Check the plan. FastRouter.ai's Starter plan does not include response caching.

Check it worked by seeing a cache-hit rate in your logs or dashboard and a drop in spend for repeated requests.

Step 5: Route easy requests to cheaper models

Not every request needs your most capable model.

  1. Group your requests by difficulty: classification, extraction and short answers versus complex reasoning.
  2. Test a cheaper model on the easy groups using your quality test set.
  3. Route by rule or with a router. FastRouter.ai's auto-router chooses by cost, latency or quality, and Orq.ai's Smart Router can send simple prompts to cheaper models.
  4. Add fallbacks so a failing provider moves traffic to another. LiteLLM, Portkey, FastRouter.ai and Orq.ai list fallbacks. For a deeper walk-through, see how to route requests across LLM providers with a gateway.

Check it worked by seeing the share of traffic on the cheaper model rise with no fall in your test scores.

Step 6: Batch work that can wait

Some jobs do not need an instant answer.

  1. List background jobs such as summarising archives, tagging documents and generating embeddings.
  2. Move them to a batch endpoint. Claude Platform lists batch processing at 50% less than standard API calls. Other providers may offer batch discounts too, so check your own provider's pricing page.
  3. Note the trade-offs: batch results arrive later, and Claude Platform notes batch processing is not Zero Data Retention eligible.
  4. Schedule batches off-peak and handle failures with retries.

Check it worked by comparing the cost per item for batch jobs with the same jobs run live.

Step 7: Set budgets, limits and alerts

Finally, make overspending hard to do by accident.

  1. Create separate keys per team, feature or customer. LiteLLM lists virtual keys with budgets and rate limits, and Portkey lists virtual keys with budgeting and rate limits.
  2. Set hard caps where the gateway supports them. FastRouter.ai and Orq.ai list budget caps and spend limits.
  3. Use a tracker for visibility across providers. BurnRate shows spend in one dashboard with workspace budgets, but those budgets do not block spending.
  4. Review spend weekly, and re-run your quality tests whenever you change a model or prompt.

Check it worked by triggering a test budget alert or limit on a non-production key.

Tools for this job compared

Tool Good fit for Pricing Stated limits
Mydentify AI Model Cost Calculator Estimating and comparing monthly API costs on the web Free Estimates exclude discounts, free tiers and taxes; does not measure quality or latency
Claude Platform Prompt caching and batch calls through Anthropic's API Paid, from $0.1, usage-based (checked 24 Oct 2026) Batch processing is not Zero Data Retention eligible; some features are in beta
LiteLLM A self-hosted gateway with keys, budgets and cost tracking Open source You run and secure it; budgets and virtual keys need Postgres; Enterprise pricing not published
Portkey Gateway with caching, budgets and observability Freemium, paid from $49/mo (checked 24 Oct 2026) Developer plan: 10k recorded logs a month, not meant for production; VPC hosting is Enterprise
FastRouter.ai Auto-routing, caching and budget caps across 200+ models Freemium, paid from $199/mo (checked 24 Oct 2026) Starter: 1M requests a month on one key, 7-day logs, no response caching; self-hosting is Enterprise
Orq.ai Smart routing, caching and budgets across 500+ models Freemium Pay-as-you-go: 4.5% fee on Orq-managed credits, 30-day data, 100 requests a minute
BurnRate Seeing OpenAI and Anthropic spend in one dashboard Freemium, paid from $12/mo (checked 24 Oct 2026) Free: up to 3 usage sources, 30 days of history; budgets do not block spending

Prices and plan limits change, so confirm the current terms on each vendor's site before you commit.

Common mistakes to avoid

  • Optimising before measuring. Teams often trim prompts that cost little while one expensive feature runs unchecked. Fix it by ranking prompts by total spend and starting at the top.
  • Switching to a cheaper model without testing. Wrong answers cost more in rework and trust than the tokens saved. Fix it by running your quality test set before and after every model change.
  • Treating a budget alert as a limit. Some tools only show spend. BurnRate's budgets, for instance, do not block provider spending. Fix it by setting hard caps in the gateway or provider account as well.
  • Trusting estimates as bills. Calculators leave out retries, tool charges, discounts and taxes. Fix it by comparing estimates with real invoices each month.
  • Caching content that should not be shared. A response cache can return one user's answer to another if keys are careless. Fix it by caching only requests that are identical and safe to share, and by keeping personal data out of cached prompts.

How we put this together

This is an evidence-based guide built from each tool's listing in our directory, which is compiled from the vendor's own site and pricing page. It is not a review based on using the tools. We don't rank tools, and nobody paid to be included. Some outbound links may be affiliate links; see our disclosure.

Frequently asked questions

What is the fastest way to reduce LLM API costs?

Find your most expensive prompt and shorten it, cap output length, and turn on caching for repeated content. These changes need no new infrastructure. Measure first so you know which prompt to target.

Is there a free tool to estimate LLM costs?

Yes. The Mydentify AI Model Cost Calculator is a free web tool that needs no account or API key. It estimates monthly cost from your request volume, token sizes and cached share, with the limits noted above.

Does prompt caching change the answers?

Caching reuses already-processed input, so it is meant to change cost and speed rather than content. Response caching returns a stored answer for an identical request, so it can serve a stale reply if your data changes. Check each provider's rules.

Do I need a gateway to save money?

No. You can shorten prompts, use provider caching and batching, and set provider-side limits without one. A gateway helps when you use several providers or teams and want routing, caching and budgets in one place, at the cost of running or paying for another service.

How do I know a cheaper model is good enough?

Run your own test set through both models and compare scores, and have a person review a sample. Public benchmarks do not tell you how a model handles your prompts.

Compare more options in our Developer platforms category.

Related guides

Developer platforms

How to add AI-powered search to your website or app

Add semantic and hybrid AI site search to your website or app: the steps, eight tools compared on pricing and limits, and the mistakes that hurt relevance.

Debuly Editorial · Published

Related categories