Most LLM cost optimization guides converge on the same five tactics: semantic caching, model routing and tiering, prompt compression, and batching. Few ask whether the query should exist at all. In one enterprise deployment, an internal review found 350 of its 400 custom-GPT agents were probably dead and unused, still running live calls nobody read the output of. This guide covers that audit first, tactic zero, then the five standard tactics, plus how Atlan’s Context Lakehouse routes shared context instead of duplicating calls.
| Field | Value |
|---|---|
| Time to complete | 4 to 8 weeks, ongoing monitoring after |
| Difficulty | Intermediate |
| Prerequisites | Agent inventory access, billing visibility, sign-off to decommission dead workloads |
| Tools needed | Caching layer, routing tool (LiteLLM, Portkey, RouteLLM), compression library (LLMLingua), Batch API access, quantization stack if self-hosting |
The six tactics below: audit inventory, cache repeated queries, route and tier models, compress prompts, batch non-urgent requests, quantize or distill.
Why does LLM cost optimization need more than cheaper models?
Permalink to “Why does LLM cost optimization need more than cheaper models?”Costs spiral from token volume and unoptimized model choice, but also from workloads that shouldn’t run at all. The widely cited rule is matching model intelligence to task complexity. But cost conversations rarely stay standalone: evidence ties spend back to agent sprawl and duplicate ownership, not just pricing tiers.
Once the workload is legitimate, the tactics stack into real savings. Per Anthropic, prompt caching cuts input-token cost up to 90 percent on cached prefixes. OpenAI and Anthropic’s Batch APIs both offer a 50 percent discount for async processing, and per Microsoft Research, LLMLingua compresses prompts up to 20x. None of that matters if the call shouldn’t be happening at all.
Any team running LLM calls at volume, especially across agents with no central registry, is ready for this: the signal is you can’t name every agent from memory. See what LLMOps is, LLMOps vs MLOps, and how to build a centralized AI platform for the fuller picture. Cost optimization stopping at pricing tiers optimizes the wrong layer: the cheaper model still has to understand the query first.
What do you need before optimizing LLM costs?
Permalink to “What do you need before optimizing LLM costs?”| Prerequisite | Type | Why it matters |
|---|---|---|
| Cross-team agent inventory | Technical | Tactic zero depends on this existing |
| Sponsorship to decommission dead agents | Organizational | Killing a workload needs sign-off |
| Billing data across every provider | Technical | Attribution needs per-provider visibility |
| A cost-per-query baseline | Organizational | Without one, nothing to measure against |
| Engineering time | Team | Every tactic beyond the audit needs code changes |
Team: a project lead at 20 to 30% FTE, an engineer for implementation, a FinOps partner, and a stakeholder to confirm which agents are still needed, the audit’s hardest call. Ownership disputes over this budget line are common; see who owns the context layer for the same question one layer up, and AI agent access control for the related access-sprawl problem.

The 6-tactic LLM cost optimization stack. Source: Atlan.
Step 1: Audit your agent and LLM call inventory
Permalink to “Step 1: Audit your agent and LLM call inventory”Before touching pricing tiers, model choice, or caching, inventory every agent, custom GPT, and automated LLM call across the org, the tactic most competitor guides skip, since it makes every other tactic more effective, not a substitute for them. Tag each with owner, purpose, and last-active date across every team and platform. Flag duplicates solving the same job, then decommission or consolidate before Steps 2 through 6.
The most common mistake is jumping straight to caching or routing without knowing what’s running: 350 of 400 agents built on one harness were probably dead before any pricing conversation started. See what a context graph is and how to implement an enterprise context layer for AI for what you’re inventorying, and AI agent observability for catching this ongoing.
The AI Context Stack
A practical brief on the layers underneath every AI initiative, from raw data to the shared context that keeps agents from duplicating each other's work.
Get the BriefStep 2: Implement semantic and prompt caching
Permalink to “Step 2: Implement semantic and prompt caching”Caching repeated and near-duplicate queries stops you from re-paying for the same call twice. Enable native prompt caching for repeated system prompts, both Anthropic and OpenAI support this, reserved for stable prefixes, not volatile data. Deploy semantic caching, GPTCache or equivalent, for near-duplicates exact-match caching misses, and set TTL and invalidation rules so stale answers never serve.
The common mistake is caching everything, including volatile data. Reserve caching for stable prefixes, and monitor cache-hit-rate alongside cost-per-1k-tokens. Rules don’t carry across providers automatically; see managing multiple LLM providers at scale.
Step 3: Route and tier models by query complexity
Permalink to “Step 3: Route and tier models by query complexity”Matching model cost to task complexity means sending simple, high-volume queries to smaller models and saving flagship models for hard tasks. Classify queries using a routing tool such as LiteLLM, RouteLLM, or Portkey, then route simple queries to smaller models and complex ones to flagship models. Classification alone is a cheap-model guess at difficulty, not a business-meaning check: the same failure mode that makes a guardrail misflag a routine industry term applies equally to cost routing.
The common mistake is routing purely on token count or a generic difficulty classifier. Route on complexity and business-context together. See model router vs model gateway for the routing architecture, and LiteLLM vs Portkey vs AWS Bedrock Gateway for a tool comparison.
Step 4: Compress prompts and reduce token volume
Permalink to “Step 4: Compress prompts and reduce token volume”The next lever is cutting what you send per call, through compression, scoped context, and trimmed system prompts. Apply a compression library, LLMLingua or equivalent, to trim non-essential tokens. Replace full-document stuffing with scoped, retrieved context, and shorten system prompts by moving shared definitions to one reference instead of retyping.
The common mistake is compressing without checking output-quality degradation; test against a baseline first. Prompt compression is becoming commodity tooling, not a differentiator, as libraries fold natively into LangChain and LlamaIndex, so invest engineering time elsewhere. See LLM context window limitations and context engineering vs prompt engineering for trimming wording versus restructuring context.
Context Layer ROI Calculator
Model the savings from routing and caching decisions that account for shared context, not just raw token counts.
Calculate Your ROIStep 5: Batch non-urgent requests
Permalink to “Step 5: Batch non-urgent requests”Asynchronous, non-real-time workloads can move to batch APIs for a flat discount. Identify workloads like nightly summarization, backfills, and bulk classification, and route them to the Batch API instead of the synchronous endpoint, since both OpenAI and Anthropic offer this. Build monitoring for completion windows, since batch jobs aren’t instant.
The most common misuse is batching real-time requests, breaking the experience. Reserve batching for asynchronous workloads only; it doesn’t help real-time applications, a nuance most vendor guides skip.
Step 6: Quantize or distill models for self-hosted inference
Permalink to “Step 6: Quantize or distill models for self-hosted inference”Once volume justifies the investment, the last lever is shrinking model size for self-hosted workloads via quantization or distillation. Confirm self-hosting is justified by volume first. Apply quantization via an inference stack such as vLLM or NVIDIA TensorRT-LLM, and consider distillation, fine-tuning a smaller model on a larger model’s outputs, for narrow, repeatable tasks.
The common mistake is self-hosting before volume justifies it. Confirm you’ve cleared the threshold, and completed Step 1’s audit, before building infrastructure a workload may not need. Multiple model versions raise the same tracking problem as agent sprawl; see AI model versioning best practices.
What goes wrong when enterprises try to cut LLM costs?
Permalink to “What goes wrong when enterprises try to cut LLM costs?”1. Optimizing token pricing on workloads that shouldn’t exist
Permalink to “1. Optimizing token pricing on workloads that shouldn’t exist”Teams jump straight to caching, routing, and compression without asking whether the agent is still needed. Run Step 1’s audit first; the same pattern is in multi-agent memory silos. Decommission the flagged workload before optimizing its pricing.
2. Routing on token count instead of business context
Permalink to “2. Routing on token count instead of business context”Routing tools classify difficulty on the query’s surface form, not its business meaning, so a cheap model gets handed a term it doesn’t understand. Layer business-context classification into routing rules, and audit misrouted queries for missed vocabulary.
3. Over-caching volatile or time-sensitive data
Permalink to “3. Over-caching volatile or time-sensitive data”Teams cache aggressively to chase cache-hit-rate without checking whether the answer stays accurate. Reserve caching for stable prefixes, set TTLs deliberately, and audit for stale answers before trusting cache-hit-rate alone.
4. Batching real-time, user-facing requests
Permalink to “4. Batching real-time, user-facing requests”Teams apply the batching discount indiscriminately without checking latency requirements. Reserve batching for asynchronous workloads only; move a batched real-time workload back to the synchronous endpoint.
Uncoordinated agents duplicating each other’s calls sits underneath most of these pitfalls; see multi-agent coordination patterns for how duplication forms, and AI security for the risk when dead agents keep live access unmonitored.
Best practices for sustaining LLM cost optimization
Permalink to “Best practices for sustaining LLM cost optimization”Track cost-per-query attributed to team, use case, and domain, not just an API key, so conversations start with who and why, not how many tokens. Treat caching and compression as table stakes: compression tooling is converging into commodity infrastructure, so invest engineering time in the inventory and routing layer instead.
Monitor cache-hit-rate and cost-per-1k-tokens as paired metrics, and re-audit inventory on a schedule, since sprawl re-accumulates. Watch the market move toward context-based cost control: a data-observability competitor shipped a cost-tracking agent and an execution-lineage product the same week in 2026, read by analysts as confirmation cost visibility is a context problem, not a FinOps one. The same discipline applies to AI observability, and the semantic layer that gives “cost per query” one meaning across teams.
How does Atlan approach LLM cost optimization?
Permalink to “How does Atlan approach LLM cost optimization?”Atlan treats LLM cost as a context and attribution problem first, a pricing-tier problem second. Gateways and routers optimize individual requests, but can’t see why a request was made, who it serves, or whether it duplicates something that exists, the blind spot behind the 400-plus-agent example above. Per Cloudoku AI’s 2026 analysis, most cost-reduction guidance stops at caching, routing, and model selection, treating cost as pricing rather than what the system knows about a query.
Atlan maps every LLM call to a team, use case, project, and domain through cost attribution, not just an API key. Context-aware routing factors in the business and compliance classification of the data, not blind token-count heuristics, and multi-provider visibility spans OpenAI, Anthropic, Bedrock, Azure, and self-hosted models in one place. Atlan’s Context Agents, Orion, Sage, Vera, Atlas, reduce the cost of rebuilding context per agent, so new agents inherit disambiguated definitions instead of a bespoke prompt from scratch, the build-once logic in how to build an AI agent harness.
Context reuse through the Context Lakehouse means context is generated once and reused across agents, cutting token volume and duplicate engineering effort together. This compounds routing, caching, compression, and batching; it doesn’t substitute for them. A flat, ungoverned estate can still cut spend through those four alone. See context engineering and context layer ROI for the internal case.
What to do after optimizing LLM costs
Permalink to “What to do after optimizing LLM costs”Track cost-per-query and cache-hit-rate as ongoing metrics, not one-time wins. Re-audit inventory quarterly: sprawl reaccumulates as new agents ship. As routing and caching mature, evolve toward context-aware decisions factoring in what a query means, not just token count.
For the full management framework this page’s tactics sit inside, see LLM cost management for enterprise. Compare best LLMOps platforms for tooling beyond single tactics, and check single-agent vs multi-agent systems if the real problem is architecture, not pricing.
Real stories from real customers: context and cost visibility at scale
Permalink to “Real stories from real customers: context and cost visibility at scale”"We're excited to build the future of AI governance with Atlan. All of the work that we did to get to a shared language at Workday can be leveraged by AI via Atlan's MCP server...as part of Atlan's AI Labs, we're co-building the semantic layer that AI needs with new constructs, like context products."
Joe DosSantos, VP of Enterprise Data & Analytics, Workday
"AI initiatives require more context than ever. Atlan's metadata lakehouse is configurable, intuitive, and able to scale to hundreds of millions of assets. As we're doing this, we're making life easier for data scientists and speeding up innovation."
Andrew Reiskind, Chief Data Officer, Mastercard
Inside Atlan AI Labs: The 5x Accuracy Factor
How governed context changes what a model routing decision can actually see, beyond token count alone.
Get the EbookWhy the standard five tactics never fully close the cost gap
Permalink to “Why the standard five tactics never fully close the cost gap”Every top-ranking guide covers the same five tactics well: caching, routing, compression, batching, and self-hosting smaller models. None connect cost to what the query means, whether the system knows it duplicates another agent’s job, or whether a cheap model can be trusted with a term it doesn’t understand. That gap is real, but isn’t absolute: a team with a flat, ungoverned estate can still cut real spend through routing and caching alone.
It’s not a claim that context work replaces the other five tactics, it’s a claim that context and inventory work is a lever most competing guides ignore, one that decides whether the other five optimize legitimate work or dead weight. The same pattern shows up in how enterprises centralize prompt management: registry, versioning, and access control are necessary and still not sufficient without governed context underneath, the same argument for AI platform architecture: control-plane decisions, whether prompts, guardrails, or cost, are only as good as the context layer feeding them.
FAQs about LLM cost optimization
Permalink to “FAQs about LLM cost optimization”1. What are the key LLM cost drivers?
Permalink to “1. What are the key LLM cost drivers?”Token volume, model choice, and prompt length are the visible drivers, but agent sprawl and duplicate workloads are a hidden one most guides skip. One deployment found 350 of 400 custom-GPT agents were probably dead, still generating live calls.
2. How can I reduce my LLM API costs?
Permalink to “2. How can I reduce my LLM API costs?”Stack six tactics: audit your agent inventory, enable prompt and semantic caching, route queries to cheaper models by complexity, compress prompts, batch non-urgent requests, and quantize self-hosted models if volume justifies it.
3. When should you use model routing instead of fine-tuning?
Permalink to “3. When should you use model routing instead of fine-tuning?”Use routing when complexity varies and you need flexibility across task types. Fine-tune a smaller model when one narrow task dominates volume; routing adds per-query overhead, fine-tuning adds upfront cost.
4. Why do LLM costs blow up even after optimization?
Permalink to “4. Why do LLM costs blow up even after optimization?”Caching, routing, and compression only optimize requests that already exist. They don’t ask whether the agent should still run, so uncontrolled sprawl reintroduces cost no pricing tactic can fix.
5. What is semantic caching versus prompt caching?
Permalink to “5. What is semantic caching versus prompt caching?”Prompt caching stores exact, repeated prefixes for instant reuse, up to 90 percent savings. Semantic caching matches queries by meaning, catching near-duplicates phrased differently that prompt caching would miss.
6. Does batching save money for real-time applications?
Permalink to “6. Does batching save money for real-time applications?”No. Batch APIs discount because requests aren’t processed instantly, unsuitable for real-time applications. Reserve batching for asynchronous workloads like nightly summarization, not anything a user is waiting on.
Sources
Permalink to “Sources”- Prompt caching, up to 90% input-token savings, Anthropic: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
- Prompt caching docs, OpenAI: https://platform.openai.com/docs/guides/prompt-caching
- Batch API docs, OpenAI: https://platform.openai.com/docs/guides/batch
- Message Batches API docs, Anthropic: https://docs.anthropic.com/en/docs/build-with-claude/batch-processing
- GPTCache, open-source semantic cache, GitHub: https://github.com/zilliztech/GPTCache
- LiteLLM, unified proxy for 100+ LLM APIs, GitHub: https://github.com/BerriAI/litellm
- RouteLLM, LLM router framework, GitHub: https://github.com/lm-sys/RouteLLM
- LLMLingua, Microsoft Research prompt compression, GitHub: https://github.com/microsoft/LLMLingua
- vLLM, inference engine with quantization support, GitHub: https://github.com/vllm-project/vllm
- NVIDIA TensorRT-LLM, FP8/INT8 quantization, GitHub: https://github.com/NVIDIA/TensorRT-LLM
- Portkey Gateway, open-source AI gateway, GitHub: https://github.com/Portkey-AI/gateway
- How to reduce LLM inference costs 20-50%, Cloudoku AI: https://cloudoku.com/llm-cost-optimization/
- The practical guide to LLM cost optimization, Alexander Thamm: https://www.alexanderthamm.com/en/blog/llm-cost-optimization/
