• Home
  • Platform
    • Platform Capabilities
    • Integrations
    • Intelligent Workflows
    • Multi Cloud Cost
    • Policy Engine
    • Cost Allocation
    • Billing Analysis
    • Rightsizing
    • Dashboards & Reports

      Platform Capabilities

      Full-stack cloud control layer

      Integrations

      Connect 200+ cloud services

      Intelligent Workflows

      Event-driven task scheduling

      Multi Cloud Cost

      Unified cost visibility

      Policy Engine

      Compliance at enterprise scale

      Cost Allocation

      Tag-based allocation & chargeback

      Billing Analysis

      Deep-dive usage anomalies

      Rightsizing

      AI-powered resource sizing

      Dashboards & Reports

      Real-time custom reporting

      Platform Preview

      CloudPi Platform

      Govern and optimize multi-cloud spending with absolute precision using neural anomaly calculations.

      Cost Optimization +40% ROI
      Security Score 99.9%
      Explore Platform
  • Solutions
    • Solutions by Role
    • Solutions by Persona
    • Why CloudPi

      Solutions by Role

      Custom tools designed for FinOps, Engineering, and Finance.

      Solutions by Persona

      Aligned with executives, managers, and system operators.

      Why CloudPi

      Four core challenges, four answers, one governed system.

      Core Outcomes

      Solutions Value

      Empower your finance, engineering, and FinOps teams to govern cloud operations collaboratively with absolute precision.

      Cost Efficiency Boost +55% Savings
      Time-to-Value Instant Day-1
      Explore Solutions
  • Company
    • About
    • Book Demo
    • Security
    • Features

      About Us

      Our mission, vision & core team.

      Book Demo

      Schedule a custom walkthrough.

      Security

      Zero-trust enterprise protection.

      Features

      Deep dive platform capabilities.

      Trust & Uptime

      About CloudPi

      We are building the future of autonomous cost optimization to help modern enterprise cloud control rooms run efficiently.

      Enterprise Trust Score 100% Secure
      Standard SLA 99.99%
      Learn More
  • Pricing
  • Resources
    • Documentation
    • FAQ
    • Videos
    • AWS S3 Cost Surge
    • Freight Manufacturer
    • API Cost Tracking

      Documentation

      User guides, configurations, and reference manuals.

      FAQ

      Frequently asked questions and support notes.

      Videos

      Walkthroughs, demos, and feature highlight videos.

      Case Studies

      Real-world cloud cost optimization outcomes and client stories.

      Resources Hub

      Learn & Grow

      Explore our collection of detailed guides, video walkthroughs, and case studies to supercharge cost controls.

      Guides & Tutorials 50+ Articles
      Demo Video Views 10K+ Watched
      Visit Learn Center
BOOK DEMO
HomeBlog How to reduce LLM API cost: what caching and model routing actually save

How to reduce LLM API cost: what caching and model routing actually save

cloudpi inc on December 5, 2026
Blog
9 Min Read

The short answer: on a request with a long, repeated system prompt, prefix caching roughly halves the bill, and routing easy traffic to a small model cuts it again. In my worked model below, 1,000 requests on Claude Sonnet 5.5 cost $25.00 uncached and $11.72 with a 90% cache hit rate [1]. Sending 70% of them to Haiku 5.5 instead brings the blend to about $3.95 [1].

The bigger point is where the money goes. Output tokens are billed at five times the input rate on all three Claude tiers I priced, and caching does nothing for them [1]. So the levers are different for input and output, and I’ll take them one at a time.

What one LLM API request actually costs

A request has up to four billable parts: ordinary input tokens, tokens written to a prompt cache, tokens read back from that cache, and output tokens. Anthropic lists all four per model, in USD per million tokens (MTok), and these are the rates I used, as listed on 5 December 2026 [1]:

ModelInput5-minute cache writeCache hitOutput
Claude Haiku 5.5 (prompts up to 100,000 tokens)$0.10$0.125$0.01$0.50 [1]
Claude Sonnet 5.5$2$2.50$0.10$10 [1]
Claude Opus 5.5$4$5$0.20$20 [1]

OpenAI’s list has the same shape: gpt-6.1-terra is $1.00 input, $5.00 output and $0.05 cached input per million tokens, and gpt-6-luna is $0.10, $0.50 and $0.01 [4]. Google’s Gemini 3.8 Flash is a useful warning about dates: its paid input price is $0.75 through December 31, 2026 and $1.50 starting January 1, 2027 [3].

Two things inflate token counts without changing your text. Anthropic says the tokenizer in Claude 4.7 and later produces approximately 30% more tokens for the same text [1]. And reasoning or “thinking” tokens are billed as output: Google labels its column “Output price (including thinking tokens)” [3].

A worked cost model: cost per 1,000 requests across three tiers

The token counts here are my assumptions, illustrative rather than measured, so swap in your own. Each request carries an 8,000-token shared prefix (system prompt plus tool definitions), 2,000 tokens of new input and 500 output tokens, priced at the rates in [1]. With caching on, 90% of requests read the prefix from a 5-minute cache and 10% write it [1].

Per 1,000 requestsHaiku 5.5Sonnet 5.5Opus 5.5
No caching$1.25$25.00$50.00 [1]
Prefix caching, 90% hit rate$0.62$11.72$23.44 [1]
Saving50%53%53% [1]

Haiku saves slightly less because its cache hits are billed at 0.1x the input price, while hits on Sonnet 5.5 and Opus 5.5 are 0.05x [1].

The saving stops near half because output is untouched: on Sonnet 5.5, the 500 output tokens alone cost $5.00 per 1,000 requests at $10 per MTok [1]. If you want a bigger cut, the output side needs its own work, which I cover under max_tokens below.

The routing line is simple arithmetic on the same table. A 70/30 split between Haiku 5.5 and Sonnet 5.5 costs $8.38 per 1,000 requests uncached and $3.95 cached, against $11.72 for cached Sonnet alone [1]. That only holds if the small model is good enough for most of the traffic, which is a quality question no price list answers. Who gets to make that trade-off, and how the spend lands back on their budget, is an organisational question I covered in a post on FinOps practices for AI and SaaS spend.

The small model has a price step to watch. A Haiku 5.5 request whose prompt is over 100,000 tokens pays $0.50 input and $2.50 output per MTok, five times the rates in the table [1]. Long-context traffic routed to the small model keeps much less of the saving.

Prompt caching vs semantic caching

These are two different mechanisms, and I think the confusion between them is most of why the debate gets heated. Prompt (prefix) caching is a provider feature: the provider stores the processed state of the start of your prompt and bills a re-use at a discount. OpenAI says plainly that “Cache reuse requires the entire rendered prefix to match” [2].

Semantic caching is something you build. You embed an incoming query, look for a similar earlier one, and return the stored answer without calling the model at all. In my view it is closer to a search index than a new idea, and I’d engineer it like one.

The best primary write-up I found is DoorDash’s engineering post from October 29, 2026 [8]. Its gateway “reuses exact or semantic cache hits”, and on a warm pass the hit rate rose from 6.2% to 99.4% while search cost per 1,000 queries fell from $0.7385 to $0.0045 [8].

Read that headline carefully, though. The widely shared “98%” is about web-search grounding: on 7,988 retail queries, search cost per 1,000 fell from $7.90 to $0.110 [8].

DoorDash writes that “Reported costs cover search-provider charges and exclude model inference” [8]. It is one company’s result on one workload, and it is not a saving on LLM tokens.

DoorDash also reports where its approach lost: “native search outperformed DSG across all five models tested” on the recency-focused FreshQA benchmark [8]. A semantic cache that serves a stored answer has the same weakness on anything time-sensitive.

Which caching breaks when you add a router

Prefix caching is fragile by design, because any change before the cached point is a miss. Anthropic’s docs say that modifying tool definitions “invalidates the entire cache”, and that changing thinking parameters invalidates cached message prefixes [10]. A router that varies the tool list or reasoning settings per route will quietly turn hits into fresh writes.

That matters because writes cost more than plain input: 1.25x for a 5-minute cache write [1]. In my model, Sonnet 5.5 with every request writing and none reading costs $29.00 per 1,000 requests, more than the $25.00 with caching off [1]. Anthropic notes caching pays off after one cache read on the 5-minute tier [1].

OpenAI’s newer models carry the same trap: for GPT-5.6 and later, cache writes cost 1.25x the uncached input rate for the default 30-minute lifetime [2].

I couldn’t find an explicit statement, in either Anthropic’s or OpenAI’s caching docs, on whether a prefix cached on one model can be read by another. The nearest is OpenAI listing model among the settings that affect the cached prefix, with the note “A different model can use different weights and caching behavior” [2].

I’d assume each route builds its own cache and plan for the write cost on every model a prefix lands on.

Two smaller traps. Anthropic won’t cache prompts shorter than 512 tokens on Opus 5.5, Sonnet 5.5 and Haiku 5.5, and returns no error when it skips them [10]. And a cache entry only becomes available after the first response starts, so a burst of parallel requests can all pay for writes [10].

How to measure cache hit rate

OpenAI gives the formula: track the token cache-hit rate “by dividing total cached tokens by total input tokens”, grouped by user, workspace or day [2]. Anthropic returns the same two counts in each response as cache_read_input_tokens and cache_creation_input_tokens [10]. For an agent, I’d log both per step, because one changed tool definition mid-session shows up as a run of writes. A hit rate is only worth tracking if someone is told when it drops, which is what budget alerts that fire while there is still time to act are for.

On OpenAI, routing itself affects hits: cached states live on individual machines, and traffic above 15 requests per minute can lead to overflow routing [2]. On models before GPT-5.6, a stable prompt_cache_key is the documented way to keep related requests together, at about 15 requests per minute per key [2]. On GPT-5.6 and later, OpenAI says it “handles cache routing automatically; the key is not needed to optimize caching” [2].

max_tokens not respected? What actually enforces the cap

On the Claude API, a response that hits the cap comes back with stop_reason set to max_tokens [6]. If a completion looks longer than the cap, my first suspect is a count made with something other than that model’s own tokenizer. The gap can be large: Anthropic says the tokenizer in Claude 4.7 and later produces approximately 30% more tokens for the same text [1].

Mind the direction, though. Counting a newer model’s output with the older tokenizer gives a lower number, so that particular mismatch would hide an overshoot, not create one.

I couldn’t verify the cause of the specific overshoot reported in the r/LLMDevs thread; no primary source I read describes a model exceeding its cap.

On reasoning models the opposite problem is common. OpenAI warns a capped response can end “before any visible output tokens are produced, meaning you could incur costs for input and reasoning tokens without receiving a visible response” [5]. It recommends reserving at least 25,000 tokens at first [5].

Can a Claude Max subscription be your API backend?

Not through the app, unless Anthropic has explicitly permitted the route you’re using. The consumer terms bar accessing the services “through automated or non-human means, whether through a bot, script, or otherwise” [7]. The clause opens with two exceptions: “Except when you are accessing our Services via an Anthropic API Key or where we otherwise explicitly permit it” [7].

What Max offers instead is $100 of monthly Claude API credit with no rollover, which you claim by linking a Claude Console organization to the plan [9]. New subscribers can claim after 7 days, and the credit covers the Claude API and the Agent SDK but not Claude Code [9].

Which lever to pull first

My opinion, from the arithmetic above: get prefix caching working before anything else, since it is a configuration change worth about half the input-heavy bill [1]. Then route, but keep each route’s prefix stable so caching survives it. Batch work that can wait gets a further 50% off on Anthropic, and the batch and cache discounts stack [1]. Turning that list into something a team runs every month is a workflow problem, which I covered separately in automating the FinOps workflow.

None of this is visible from a provider invoice, which arrives with no team or feature dimension. If you buy these models through Amazon Bedrock, Azure OpenAI or Vertex AI, CloudPi's AI cost analytics allocates that spend through the same projects and dimensions as the rest of your cloud bill. API bills paid directly to OpenAI, Anthropic or Google aren’t covered today.

Sources

  1. Pricing – Claude Platform Docs (Anthropic)
  2. Prompt caching | OpenAI API
  3. Gemini Developer API pricing (Google)
  4. Pricing | OpenAI API
  5. Reasoning models | OpenAI API
  6. Stop reasons and fallback – Claude Platform Docs
  7. Consumer Terms of Service – Anthropic
  8. How DoorDash Reduced LLM Search Costs by 98% Without Losing Accuracy – DoorDash Engineering
  9. API credits for Max, Ultra, and Team plans – Claude Platform Docs
  10. Prompt caching – Claude Platform Docs
cloudpi inc on December 5, 2026 Blog
previous article
Next article

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *

About CLOUDPI

CloudPi Editorial Team

Cloud Cost Optimization & FinOps Specialists

Expert insights on FinOps, cloud cost optimization, governance, and automation for modern cloud teams.

  • X
  • Instagram
  • LinkedIn
  • YouTube

FEATURED POSTS

categories

  • AWS 4
  • Blog 13
  • Cloud Cost Optimization 42
  • CloudPi 13

related articles

  • CloudWatch Logs cost by log group: how to find and reduce log ingestion costDecember 5, 2026
  • How to reduce LLM API cost: what caching and model routing actually saveDecember 5, 2026
  • What Connectors Do You Need for Multi-Cloud Governance? A Practical Map for AWS, Azure and GCPDecember 4, 2026

popular tags

Cloud Cost Management Cloud Cost Optimization CloudCostOptimization CloudCostSavings CloudEfficiency CloudManagement CloudOptimization CloudPi CloudSavings FinOps Multi-Cloud Management

Read next
CloudWatch Logs cost by log group: how to find and reduce log ingestion cost
cloudpi inc on December 5, 2026
To find which log group drives your CloudWatch Logs bill, rank log groups by the...
How to Get Unified Cloud Visibility Across AWS, Azure, and Google Cloud 5 Min
How to Get Unified Cloud Visibility Across AWS, Azure, and Google Cloud
CloudPi-Blogs on July 30, 2026
Unified cloud visibility means seeing spend, usage, and resource inventory across AWS, Azure, and GCP in one place,...
AWS vs Azure vs GCP: Which Cloud Is Actually Cheaper for Your Workload? 5 Min
AWS vs Azure vs GCP: Which Cloud Is Actually Cheaper for Your Workload?
CloudPi-Blogs on July 28, 2026
“Which cloud is cheapest” is the wrong question for an AWS vs Azure vs GCP cost comparison, and...

CloudPi helps organizations gain visibility into multi-cloud spending, optimize infrastructure costs, and enforce governance across AWS, Azure, and Google Cloud environments.

AvailableInMarket-AWS-DUHaQVhh

Stay ahead of cloud cost optimization trends.

PLATFORM
  • Platform Capabilities
  • Integrations
  • Intelligent Workflows
  • Cloud Cost Analytics
  • Policy Engine
  • Pricing
COMPANY
  • About Us
  • Features
  • Contact Us
  • Careers
  • Security
  • Privacy Policy
  • Terms of Service
RESOURCES
  • User Guide
  • Press Releases
  • FAQ
  • Case Studies
  • Blogs
  • Events
  • Webinars

categories

  • vs. Finout
  • vs. CloudZero
  • vs. Apptio Cloudability
  • vs. PointFive
  • vs. ProsperOps
  • vs. Harness

© 2026 CloudPi. All rights reserved.

Back to top