Skip to content
AI30 August 2026 · 8 min readUpdated 30 September 2026

SaaS AI Cost Control in 2026: Caching, Routing, Fallbacks

A usage limit caps your worst month without touching your average one. The savings live in four layers underneath it: prompt caching, semantic caching, model routing, and fallbacks.

SaaS AI Cost Control in 2026: Caching, Routing, Fallbacks

Your provider invoice and your MRR dashboard are getting closer together, and nothing broke. Usage grew, and model spend grew with it, linearly, because that is how per-token pricing works. Before you read further, open the last invoice and find one number: how many of your input tokens were cache reads. If you can't find it in under a minute, that is your first task.

Most advice on LLM cost optimization stops at "set a usage limit." A limit is a circuit breaker. It stops the worst month but leaves the average one untouched. The savings sit in four layers underneath it: a prompt cache, a semantic cache trusted with one narrow slice of traffic, a router that sends most requests to a cheap model, and a fallback chain that degrades instead of failing.

This post walks through those layers in the order I'd build them, with prices and limits checked against vendor documentation on 30 September 2026. Prices change often, so every number below carries its source and you should re-check it before you budget.

Why does LLM cost optimization fail at the usage-limit stage?

Isometric illustration of an oversized shut-off valve clamped on a pipe while the same orange flow keeps circulating through a wide bypass loop behind it, rust bleeding down from the valve bolts

A usage limit caps your worst month without lowering your average one, because the cost sits in the shape of every request rather than in how many requests you send.

Consider a typical request in a B2B product: a system prompt, a tool schema, tenant configuration, a few thousand tokens of retrieved context, then a user message of forty tokens. You pay full input price for all of it, and the first four parts are identical to the last ten thousand requests. That redundancy is the leak. Volume is only the multiplier.

There is also a hard-stop version of the limit you should know about. Anthropic's rate-limit documentation says that when your organization reaches its monthly spend cap, requests return HTTP 429 with no retry-after header, and retrying, including the SDKs' automatic retries, fails until access resumes. A cap protects your budget. It also switches your product off for every tenant at once, so treat it as the last line and not the plan.

How do prompt caching and LLM model routing cut the bill?

Prompt caching bills a repeated prefix at a fraction of the input price, and LLM model routing sends each request to the cheapest model that can handle it, and both work without changing what the product does.

What does Anthropic prompt caching pricing look like?

Isometric illustration of a conveyor line where identical crates are diverted onto a short return loop back to the head of the line instead of being rebuilt, one crate sitting askew with its tape peeling

Anthropic's pricing page lists a five-minute cache write at 1.25x the base input price, a one-hour write at 2x, and a cache read at 0.1x for most models, with 0.05x on Claude Opus 5.5 and 0.025x on Claude Fable 5.1 and Claude Mythos 5.1. The same page says caching pays off after one read for the five-minute duration and after two reads for the one-hour duration. OpenAI's prompt-caching guide describes a similar shape: caching is on by default, and on GPT-5.6 and later a cached read costs 0.1x the uncached input rate, with a 1,024-token minimum.

Where do I place the breakpoint so the cache actually hits?

Put the breakpoint on the last block that is identical across requests. Anthropic's prompt-caching documentation warns about the common mistake: a breakpoint on a block that contains a timestamp or the user message writes a fresh cache entry on every request and never gets a read, so you pay the write premium for nothing. Three more rules from the same page matter in production:

  1. Invalidation runs in order. Prefixes are built as tools, then system, then messages, and a change at one level invalidates that level and everything after it. Editing a tool definition throws away the cache for the whole prompt.
  2. Short prompts don't cache, and nothing tells you. The minimum cacheable prefix is 512 tokens on some models and 4,096 on others, and below it the request is processed without caching and no error is returned.
  3. You get four breakpoints. Automatic caching uses one of them if you combine it with explicit ones.

The second benefit doesn't appear on the pricing page. For most Claude models, cache read tokens don't count toward the input-tokens-per-minute limit, and Anthropic's own example describes a 2,000,000 ITPM limit with an 80% cache hit rate handling about 10,000,000 input tokens per minute. Claude Haiku 3.5 is an exception, but it is retired on Anthropic's own API. Verify the win by checking that cache_read_input_tokens is non-zero in the response usage, not by trusting the config.

Which model should get the request?

Route on a signal you already have, default to the cheap tier, and escalate only on evidence that the cheap answer failed.

The research version is RouteLLM, where Ong and colleagues train routers on preference data and report that costs can fall by over 2 times in certain cases without compromising response quality. The production version is usually simpler, because you know things a benchmark can't: which feature made the call, which plan the tenant is on, and whether a tool result is already in context.

The price gaps are what make routing worth the effort. Base input and output prices per million tokens on Anthropic's pricing page:

ModelInputOutputCache read
Claude Haiku 4.5$1$5$0.10
Claude Sonnet 5.5$2$10$0.20
Claude Opus 5.5$4$20$0.20

The same pattern shows up at OpenAI. Its pricing page lists GPT-5.6 Luna at $0.20 input and $1.20 output, Terra at $2 and $12, and Sol at $4 and $20, and it now also lists a GPT-6 line. Catalogs move fast enough that a threshold tuned last quarter may be tuned against arithmetic that has stopped being true.

A routing rollout that holds up:

  1. Ship the cheap tier as the default. A router that defaults to the expensive model stays there, because nobody gets paged for spending money.
  2. Escalate on logged evidence. A structured-output parse failure, a refusal, a low confidence field, or a user pressing regenerate are all signals you can record today.
  3. Track escalation rate per feature. A feature that escalates most of the time needs pinning to the strong model and pricing accordingly, not a cleverer router.
  4. Re-run the arithmetic every quarter, the way you'd renew a TLS certificate.

Is a semantic cache worth building?

Isometric illustration of a parcel sorting chute with a small amber approval lamp glowing calmly above it while two nearly identical parcels pass through, the chute lip dented from an earlier pass

Only for a bounded set of questions, and only with an evaluation suite, because the threshold that makes it profitable is also the one that makes it wrong.

Portkey's April 2026 threshold analysis reports a benchmark that makes the trade-off concrete:

Similarity thresholdHit rateAccuracyCost savings
0.9923.5%92.1%15.8%
0.9556.0%92.6%51.9%
0.8087.6%91.8%84.6%

Read the accuracy column twice. Raising the threshold from 0.80 to 0.99 cut savings from 84.6% to 15.8% while accuracy moved by well under one point. In that benchmark, then, a stricter threshold mostly buys you fewer hits, not fewer wrong answers. This suggests a semantic cache needs a domain filter and a review step, not just a higher number. Portkey's own guidance is to start in the 0.90 to 0.95 range and to aim for accuracy above 99% in production.

The failure mode is the real cost. A bad semantic hit returns a plausible answer with HTTP 200, so no error rate exists to alert on. A prompt-cache miss just costs you a normal call. The two layers deserve very different levels of trust.

Where it earns its place is a bounded question space, such as support macros or glossary lookups, or the stable set of questions new tenants ask in their first week in a B2B SaaS product. Cache those and send everything else past it.

What stops one tenant from eating the whole AI budget?

Enforce per-tenant ceilings on the server, before the model call, with an hourly limit and a daily one, and keep a fallback that degrades instead of retrying.

On Callidus OS, the multi-tenant clinic SaaS I built solo on React, TypeScript and Firebase, the case study documents the Calia assistant running on Vertex AI through the @google/genai SDK, with 30-per-hour and 100-per-hour rate limits, thirteen injection regex patterns and a 90-day GDPR cleanup. Everything lives under tenants/{tenantId}/ in Firestore, with tenantId and role carried in JWT claims. That gives the budget check a tenant to attribute spend to before it does anything else. Consider a hypothetical: on a £15/month plan, one enthusiastic user running ninety queries in an afternoon is a real cost you can only size if you know your per-query price. Enforce the limit client-side and you've written a suggestion, not a limit.

How should fallbacks behave when a provider says stop?

Back off with jitter, switch provider, then return a degraded answer that says it is degraded. OpenAI's rate-limit guide recommends exponential backoff with jitter and warns that unsuccessful requests count toward your per-minute limit, so resending in a tight loop cannot work. Anthropic's 429 responses carry a retry-after header for ordinary rate limits, and honoring it beats guessing. The saving hides in the last step: a graceful "try again shortly" costs nothing, and a retry storm bills you repeatedly for answers nobody received.

The metric that matters is AI cost per tenant per month, sorted descending, because the tail is where margin goes. For the broader question of which features deserve metering at all, see AI SaaS solutions for business. If you are still choosing what to build on, the SaaS MVP stack guide covers the layer below.

In what order should I build all this?

Instrument first, cache second, cap third, route fourth, add fallbacks fifth, and treat the semantic cache as optional.

  1. Instrument. Log input, output and cached tokens, model, tenant and feature on every call. Without this everything else is guesswork.
  2. Turn on prompt caching. Highest saving per hour of work, no product change.
  3. Add per-tenant ceilings. They convert your worst-case bill from unbounded to arithmetic.
  4. Add routing, cheap tier first, and watch escalation rates for two weeks before touching a threshold.
  5. Add fallbacks with backoff and jitter.
  6. Consider a semantic cache last, for a bounded question set, with a backtested threshold. The same tooling-moves-faster-than-your-assumptions discipline runs through my AI-augmented development workflow.

Open your most recent invoice and calculate cache reads as a share of total input tokens. What is the number, and which feature is responsible for the biggest gap between it and 100%?

Free resource

Free SaaS MVP Scope Template

A Notion document with the full feature checklist, MVP vs. nice-to-have table, pre-build questions, and cost signals — so you walk into any developer call knowing exactly what to ask for.

Get the template →
DL

Dusko Licanin

Full-Stack Developer · Banja Luka, Bosnia

Full-stack developer shipping SaaS MVPs, web apps, and mobile apps using AI-augmented workflows — without agency coordination overhead. Live portfolio: BookBed, Callidus, Pizzeria Bestek.

Frequently Asked Questions

How do I reduce LLM API costs in a SaaS product?

Start with prompt caching and model routing, because neither changes what your product does. Anthropic's pricing page lists cache reads at 0.1x the base input price for most models, and OpenAI's prompt-caching guide gives GPT-5.6 and later the same 0.1x rate on cached input. After that, default requests to a cheaper tier and escalate only when a structured-output parse fails, the model refuses, or a user regenerates. Log input, output and cached tokens per tenant and feature first, or you are optimizing a number you cannot see. Re-check prices each quarter, because vendor catalogs change quickly.

How much does Anthropic prompt caching cost?

A cache read costs 0.1x the base input price for most Claude models, while writes cost more than a normal request. Anthropic's pricing page lists a five-minute write at 1.25x and a one-hour write at 2x, with reads at 0.05x on Claude Opus 5.5 and 0.025x on Claude Fable 5.1 and Claude Mythos 5.1. Caching pays off after one read for the five-minute duration and after two reads for the one-hour duration. The minimum cacheable prefix runs from 512 to 4,096 tokens depending on the model, and below it nothing is cached and no error is returned.

What is LLM model routing and does it hurt quality?

LLM model routing sends each request to the cheapest model that can handle it, and research suggests quality can hold up when the router is good. The RouteLLM paper by Ong and colleagues, arXiv 2406.18665, reports cost reductions of over 2 times in certain cases without compromising response quality. In production you rarely need a learned router. Route on the calling feature and input length, then escalate when a structured-output parse fails or a user regenerates. Track the escalation rate per feature, because a feature that escalates most of the time should simply run on the stronger model.

How do I set an AI budget for a SaaS product?

Set it per tenant and enforce it on the server before the model call, not after it. A global budget tells you that you overspent, while a per-tenant ceiling tells you which customer did it and stops them at the limit. Anthropic's rate-limit documentation also describes a monthly organization spend cap that returns HTTP 429 with no retry-after header, which pauses every tenant at once, so treat it as a last resort. On Callidus OS, the case study documents 30-per-hour and 100-per-hour limits on the Calia assistant, with tenant identity in JWT claims.

Is a semantic cache worth building?

Only for a bounded question set with an evaluation suite, because a wrong hit returns a confident answer with HTTP 200. Portkey's April 2026 threshold analysis reports a 0.99 similarity threshold with a 23.5% hit rate, 92.1% accuracy and 15.8% cost savings, and a 0.80 threshold with an 87.6% hit rate, 91.8% accuracy and 84.6% savings. Accuracy barely moved while savings changed a lot. Prompt caching and routing deliver most of the saving without that risk, so build them first and treat the semantic cache as optional.