Key points of this article (Published: July 1, 2026) By combining 5 patterns, you can cut LLM production costs by 50-80% (estimates in the body). Choose where to start using the quick-reference table below. Pattern | Impact | Difficulty of adoption: 1. Prompt caching: Max / Low. 2. Context compression: Medium / Medium. 3. Model tiering (small → large): High / Medium. 4. Batch processing / Batch API: Medium / Low. 5. Moving from LLM extraction to in-house extraction: High / High. The core of the design is "a mechanism that prevents exceeding the budget cap" and "monthly measurement → improvement". → Consult on LLM cost optimization

Who this article is for

  • SRE / platform engineers whose production LLM costs are starting to exceed expectations
  • CFOs / business owners designing the unit economics of AI features
  • AX promotion leads responsible for budget management of LLM products / agents
  • Anyone who has just integrated Claude / GPT / Gemini into their workflows and wants to understand actual operating costs

Token cost basics: the 3 layers of input / output / cache

As of 2026, the pricing structure of major LLMs has a 3-layer structure.

LayerDescriptionRelative unit price (approximate)
Input tokensTokens sent to the model as the prompt1.0x (baseline)
Output tokensTokens generated by the model3-5x (more expensive than input)
Cache writeWriting to the prompt cache1.25x (input +25%)
Cache readReading from the cache0.1x (10% of input)

The key points are as follows.

  • Since output tokens are the most expensive, designs that compress output or re-summarize after output are effective
  • Cache reads are 10% of input. In production operations that reuse the same prompts, leveraging the cache has the biggest impact
  • Short prompt + short output is cheaper than long prompt + short output. Context compression is the next most effective

Each provider's pricing structure is compared in LLM API comparison.

Five cost-saving patterns

Pattern 1: Prompt caching (max impact / difficulty: low)

Anthropic, OpenAI, and Google all offer caching features. On a cache hit, reads cost 10-25% of input.

The implementation method is as follows.

  • Designate the system prompt / shared instructions / large RAG results as cache targets
  • Anthropic requires explicitly specifying cache_control: { type: "ephemeral" } (TTL 5 minutes)
  • OpenAI / Google use automatic caching (24-hour TTL)

Typical effect: 30-60% cost reduction for agent operations / chatbots. The longer the prompt, the more effective it is.

The caveats are as follows.

  • If not reused within 5 minutes, the cache expires → costs increase (the 25% cache write premium is wasted)
  • Loops with long sleeps don't benefit from caching → design loops to run within 270 seconds

Pattern 2: Context compression (medium impact / difficulty: medium)

Compress conversation history / RAG results / system prompts.

The implementation method is as follows.

  • Summarization compression: Summarize long text with a small model (Haiku / GPT-4 mini) before passing it to the main model
  • Trimming: Keep only the most recent N turns and replace earlier ones with summaries
  • Structured extraction: Convert natural language → JSON / YAML to reduce tokens

Typical effect: 20-40% reduction in chat operations. The longer the conversation, the more effective it is.

The caveats are as follows.

  • If compression loses information, decision quality drops → preserve important constraints / numbers in structured fields
  • The summarization model also costs money → only worth it when the savings vs. the main model pay for it

Pattern 3: Model tiering (small → large escalation) (high impact / difficulty: medium)

Switch models according to task difficulty.

The implementation method is as follows.

  • Stage 1: Use Haiku / GPT mini / Gemini Flash for classification / extraction / simple responses
  • Stage 2: Escalate only cases classified as "difficult" to Opus / GPT / Gemini Pro
  • If stage 1 accuracy is around 80%, overall costs can be reduced by 70-90%

Typical effect: 50-80% reduction for customer support / document classification.

The caveats are as follows.

  • If the routing classifier makes mistakes, the escalation rate rises
  • Stage 1 model accuracy must be measured continuously

Automating classification is covered in detail in LLM routing.

Pattern 4: Batch processing / Batch API (medium impact / difficulty: low)

Trade real-time responsiveness for a large unit-price discount.

The implementation method is as follows.

  • OpenAI / Anthropic / Google all offer batch APIs
  • 50% off the regular API (OpenAI / Anthropic)
  • Up to 24 hours to complete (often finishes within a few hours in practice)

Typical effect: 40-50% reduction for daily batch workloads (report generation / document summarization / data extraction).

The caveats are as follows.

  • Not applicable to use cases requiring real-time responsiveness
  • Batch completion notifications and retry handling on failure must be designed separately

Pattern 5: Moving from LLM extraction to in-house extraction (high impact / difficulty: high)

Replace LLM-based extraction processing with rule-based / existing libraries.

The implementation method is as follows.

  • Email extraction: Use the email-parser library instead of an LLM to extract From/To/subject
  • PDF text extraction: Use pdfplumber / unstructured instead of an LLM → LLM only in later stages
  • JSON / CSV parsing: Use standard parsers instead of an LLM
  • Language detection / sentiment analysis: Replace with small classification models (FastText / DistilBERT)

Typical effect: 70-95% reduction for extraction-type tasks. However, coverage is limited.

The caveats are as follows.

  • Not everything can be removed from LLM extraction → keep the LLM for cases where structuring is difficult
  • Maintenance costs for the extraction pipeline increase → only pays off for long-term operation projects

Designing a budget management harness

Treat the budget cap as a Hard Ceiling

Implement the budget as a Hard Ceiling (absolute limit), not a "target value."

const budget = { total: 50_000, spent: 0 }
async function callLLM(prompt: string) {
  if (budget.spent >= budget.total) throw new Error("Budget exceeded")
  const result = await llm.call(prompt)
  budget.spent += result.usage.input_tokens + result.usage.output_tokens
  return result
}

With a loose cap ("target X yen, report actual Y yen"), edge cases can cause exponential cost explosions. A Hard Ceiling is the minimum line for operational safety.

Behavior on overrun (fail fast / degradation / notification)

There are three patterns of behavior when the budget is exceeded.

  • Fail fast: Stop immediately with an error. Recommended for enterprises
  • Degradation: Switch from a high-end model to a small model and continue. For tasks with moderate cost sensitivity
  • Notification only: Continue after overrun, with humans deciding via Slack notifications. Prototype phase only

In production, fail fast + immediate notification is the rule. Degradation carries a risk of accuracy loss.

Monthly budget and daily burst control

Budget management is done at two levels.

  • Monthly budget: The fiscal-year budget frame (approved by management)
  • Daily burst control: Set the daily cap at 2-3x the monthly budget divided by 30. Prevents exhausting it early in the month

Without daily burst control, 80% of the monthly budget can be consumed in the first week of the month, leaving the system effectively shut down at month-end.

Actual measurement and improvement loop

Metrics

MetricCalculationTarget
Cache hit rateCache-read tokens / total input tokens50% or more (after 3 months of operation)
Avg tokens per taskTotal tokens / number of tasksDepends on task characteristics (review baseline monthly)
Cost per outcomeMonthly cost / business KPI improvementSet target linked to business KPIs
Escalation rateHigh-end model calls / total calls20-30% (when operating with model tiering)

Improvement loop (monthly)

  • Measure: Visualize the 4 metrics above on a monthly dashboard
  • Analyze: Identify the Top 10 high-cost use cases
  • Hypothesize: Consider which of the 5 patterns applies
  • Implement: Try just one and measure the effect (A/B for 1-2 weeks)
  • Production rollout / inventory: Roll out to production if effective, withdraw if not

Introducing multiple measures at once makes their effects indistinguishable. One measure per month is the rule.

Three anti-patterns

Anti-pattern 1: Stuffing everything into the context window

"Claude has a 1M context, so just put everything in" is the most wasteful pattern. Input tokens are cheaper than output, but even so, 100K input without caching costs $0.3-1 per call.

Countermeasure: Limit to the minimum necessary context. Use RAG / search to retrieve only the needed parts.

Anti-pattern 2: Processing all requests with a high-end model

"Use Opus for everything and quality will come" is a model choice at 50x unit price. Monthly costs become 10-30x.

Countermeasure: Leave classification / extraction / simple responses to small models, and call high-end models only for cases requiring judgment.

Anti-pattern 3: Iteration without using caching

An implementation that sends the same system prompt every time without using the cache feature is paying 1x for something that could cost 0.1x.

Countermeasure: Explicitly enable prompt caching. For Anthropic, specify

cache_control

.

FAQ

Q1. Can prompt caching be used outside Anthropic?

Yes.

  • Anthropic: Explicit cache point specification (5-minute TTL, paid)
  • OpenAI: Automatic caching (GPT-4 and later, 24-hour TTL, free)
  • Google Gemini: Explicit caching (time can be specified, paid / there is also a free version with automatic caching)

Anthropic offers the most implementation flexibility, but automatic caching is more convenient on OpenAI / Google. In production, create a layer that abstracts implementation differences per provider.

Q2. Which metric should be measured first?

The first to look at is Cost per outcome (cost per business KPI improvement). Next, use Avg tokens per task to identify outliers. Cache hit rate is a metric for medium-term improvement potential.

Looking only at total cost reveals no room for improvement. Always evaluate by dividing by "per X."

Q3. How to automate model tiering decisions?

There are three patterns.

  • Rule-based: Branch on input length / metadata (simple / low flexibility)
  • Small classification model: Decide with DistilBERT etc. (medium speed / medium accuracy)
  • Small LLM classification: Use Haiku etc. for classification → escalate to Opus if needed (medium cost, high accuracy)

The standard flow is to start with rule-based logic, then evolve to small LLM classification once operational data accumulates.

Q4. How much cheaper is the Batch API?

OpenAI / Anthropic offer 50% off, while Google depends on the period and SKU. Applying it to daily batch tasks (reports / data extraction / document summarization) immediately cuts costs in half.

Apply it only to tasks that can tolerate up to 24 hours of delay. It cannot be used for real-time tasks.

Q5. Who should be responsible for cost management?

Divide responsibility into the following three tiers.

  • CFO / Executive leadership: Approval / auditing of monthly and annual budgets
  • AX promotion lead: ROI evaluation at the initiative level / budget allocation
  • SRE / Platform engineers: Cost optimization at the implementation level / daily monitoring

If any of the three tiers is missing, cost management breaks down. In particular, "the CFO approved it but SRE didn't implement it" is the most common pattern.

Q6. What should be done when the monthly budget is exceeded?

Respond with the following three steps.

  • Immediate: Fail fast — stop or degrade the service
  • Within 24 hours: Identify the cause (burst in a specific use case / explosion due to prompt changes / a bug)
  • Within the month: Permanent countermeasures (prompt revision / adding model tiering / budget cap adjustment)

Treat budget overruns as incidents. Conduct incident reports / post-mortems and institutionalize recurrence prevention.

FDX's LLM Cost Optimization Support

FDX Inc. supports cost optimization for LLM production operations through Forward Deployed Engineers (FDE) + platform engineering.

  • Current cost diagnosis (identifying the top 10 high-cost use cases)
  • Design of optimization measures adapting the 5 patterns to business needs
  • Implementation of a budget management harness (Hard Ceiling / daily burst control / monthly reviews)
  • Accompaniment through improvement loops for 3–6 months after implementation

For the typical problem of "the PoC passed, but production costs turned out to be 5 times the estimate," we redesign it structurally (see: 5 Structural Reasons Why AI PoCs Fail).

Related Articles

Summary

  • LLM costs have a three-layer structure of input/output/cache, with output tokens being the most expensive and cache reads the cheapest
  • Costs can be reduced by 50–80% with the 5 patterns: prompt caching, context compression, model tiering, batch processing, and migrating to in-house extraction
  • Implement budgets as a Hard Ceiling (absolute limit), and in production follow the principle of fail fast + immediate notifications
  • Measure 4 metrics such as Cost per Outcome monthly, and run an improvement loop with one initiative per month
  • The three major anti-patterns are stuffing in the entire context, using high-tier models for all requests, and not leveraging caching
  • FDX Inc. supports everything from current cost diagnosis to implementing a budget management harness and accompanying improvement loops

Sources and References

  • Anthropic Documentation "Prompt Caching"
  • OpenAI Documentation "Batch API / Prompt Caching"
  • Google AI Documentation "Gemini Context Caching"
  • Anthropic Engineering Blog "Operating LLMs in Production"
  • Stripe Engineering "LLM Cost Patterns"
  • ACM Queue "Operating Systems for Foundation Models"
  • METI "Generative AI Usage Cost Survey 2026"