← All writing

ai-adoption · saas · cost-optimisation · prompt-caching · business-case

Cost Optimisation: some models are just cheaper

Share:LinkedInX (Twitter)

A £3 budget alert sent me down the AI-model-pricing rabbit hole. What I found - sneaky caching costs, order-of-magnitude spread between models, and why the answer for most SaaS chat workloads is boring.


The details of this report are unashamedly generated by AI to support me doing some business case work for a particular SaaS product.

I was in the process of building out a Software as a Service product that makes use of embedded AI to support data capture and decision making and came across a challenge.

One of my code changes had caused it to start to consume my API credits on Anthropic. I keep these pretty lean as I am on a budget, so when my alert went off that I had gone over my budget (a modest £3, yes I know I am tight,) I realised I was missing some important metrics. So I decided to dig.

To my surprise I found that there was a huge disparity across the range of models, and being cost conscientious, realised that there are some really cheap and effective models out there.

To save you the pain of reading this whole rather technical document here is the summary:

  1. Context caching via API is a great way to save some token usage and greatly encouraged. (Remembering that you cant really cache different users configurations and content)
  2. There are sneaky costs to content caching that you need to watch out for and you will get charged for them.
  3. At the moment Gemini 2.5 flash is the cheapest well known model that is out there.
  4. The use of the per turn phrase is a standard nomenclature for a single LLM API round trip.
  5. If you don't cache some of the content for these round trips it becomes cumulatively expensive.
  6. A lot of the models have implicit caching (it tries its best to cache).
  7. Explicit caching can help your API calls be more cost effective.

I do encourage you to peruse the rest of the article.

The analysis covers prompt caching architecture, and covers the state of the market as of July 2026.


1. Validation of the Original Table

The formula used in the original comparison - (input_tokens / 1M × input_$) + (output_tokens / 1M × output_$) - is arithmetically correct.

The output figures were correct for the input prices used, but the base input price for Gemini 2.5 Flash was stale ($0.075/M reflected an earlier pricing tier that Google retired). Current published rate is $0.30/M input · $2.50/M output. Every row using Gemini 2.5 Flash in downstream tables reflects the corrected figure.

Benchmark turn: 5,000 input + 500 output tokens (typical Overture planner chat turn from live measurement).

Math check (Gemini 2.5 Pro, unchanged):

Cost = (5,000 / 1,000,000 × $1.25) + (500 / 1,000,000 × $5.00)
     = $0.00625 + $0.00250
     = $0.00875

$0.00875 × 1,000 turns = $8.75


2. Context Caching Architecture

The multi-tenant SaaS cache-split pattern used in Overture:

  ┌─────────────────────────────────────┐
  │ FIXED (cache_control: ephemeral)    │  ← Cached: SAFE to share across tenants
  │ • Base persona                      │
  │ • Response protocol                 │
  │ • Section markers rules             │
  │ • PLAN_SECTIONS list                │
  │ • Voice guardrails                  │
  ├─────────────────────────────────────┤  ← Cache breakpoint
  │ TENANT-SPECIFIC (never cached)      │  ← Fresh every call
  │ • your session specific data        │
  └─────────────────────────────────────┘

Why this ordering is right

  1. Prefix alignment. Caches key on exact byte-for-byte prefix. Putting shared static content first guarantees a warm cache across every request from any tenant.
  2. Tenant isolation invariant. With a single shared API key across all customers, cached content is content-addressed - it doesn't leak between tenants unless two tenants generate identical prefixes. Everything above the breakpoint is generic; nothing below it is cached. Cross-tenant contamination is architecturally impossible.
  3. Dynamic-first-tail rule. The most-variable content (user message, current turn state) belongs at the absolute tail, so a change there never invalidates the cache. Our layout complies.

3. Prompt Caching Mechanics by Provider

FeatureAnthropic (Claude)Google Gemini 2.5OpenAI (GPT-4o)DeepSeek (unverified)
Trigger mechanismExplicit (cache_control block)Explicit (Context Caching API) + implicit auto-caching on 2.5 seriesAutomatic (prefix-matching)Automatic (prefix-matching)
Minimum cache sizePer model - see belowNot publicly specified on 2.5-flash1,024 tokens1,024 tokens
Cache read discount90% off input rate (0.1× base)90% off input rate ($0.03/M vs $0.30/M base on Flash)50% off input rate~90%+ off (varies)
Cache write cost+25% on 5-min write / +100% on 1-hourStorage-only (no write premium)FreeFree
Storage costNone$1/M tokens/hour (2.5 Flash) · $4.50/M/hr (2.5 Pro)NoneNone
Cache TTL5 min (ephemeral) or 1 hourConfigurable; 5-min default in the SDK we use~5-10 min~10 min

Anthropic - verified per-model cache minimums (from platform.claude.com/docs)

ModelMinimum cacheable prompt
Claude Fable 5, Mythos 5512 tokens
Claude Opus 4.8, Sonnet 5, Sonnet 4.6, Sonnet 4.5, Haiku 4.51,024 tokens
Claude Opus 4.72,048 tokens
Claude Opus 4.6, Opus 4.54,096 tokens
Claude Haiku 3.52,048 tokens

Prompts below the minimum are silently processed without caching - no error is returned. Overture's cached prefix is ~1,400 tokens, above Haiku 4.5's 1,024-token floor, so our caching works. If we drop the prefix below 1,024 tokens in a future revision, caching will silently no-op - worth a regression test.

Gemini - implicit caching on 2.5 series

Google added implicit prompt caching for 2.5-flash and 2.5-pro in early 2025 - identical prompt prefixes across requests are automatically discounted with no storage fee and no explicit API call. This is why Overture's gemini.ts no longer uses GoogleAICacheManager - the implicit path handles the fixed-prefix discount for free, and the explicit path is a net cost at our current volume because of the $1/M/hour storage fee.

Gemini - break-even for explicit caching (2.5 Flash)

At corrected pricing ($0.30/M base, $0.03/M cache read):

  • Savings per read: 1,400 tokens × ($0.30 − $0.03) / 1M = $0.000378
  • Storage cost per hour: 1,400 × $1 / 1M = $0.0014
  • Reads needed per hour to break even: ~4

At even modest traffic, Gemini explicit caching is profitable. Our earlier analysis using the stale $0.075/M base rate showed break-even at ~18 reads/hour, which was misleading. Nevertheless, implicit caching dominates - same discount, zero storage fee, zero code to manage.


4. Expanded Model Pricing Table (Standard Turn)

Benchmark: 5,000 input + 500 output tokens · standard (uncached) rates.

[!NOTE] Tokenizer footnote. Claude Fable 5, Mythos 5, Opus 4.7 and later Opus, Sonnet 5 use a newer Anthropic tokenizer that produces ~30% more tokens for the same English text than earlier Claude models. On a like-for-like text basis, real-world cost for these models is proportionally higher than the naive per-token table below suggests.

ModelInput ($/M)Output ($/M)Per turnPer 1,000 turnsStatus
Claude Haiku 4.5$1.000$5.00$0.00750$7.50Verified · Anthropic docs
Gemini 2.5 Flash ¹$0.300$2.50$0.00275$2.75Verified · ai.google.dev
Gemini 2.5 Pro$1.250$5.00$0.00875$8.75Verified · ai.google.dev
Claude Sonnet 5 (intro through 31 Aug 2026) ²$2.000$10.00$0.01500$15.00Verified · Anthropic docs
Claude Sonnet 5 (from 1 Sep 2026) ²$3.000$15.00$0.02250$22.50Verified · Anthropic docs
Claude Sonnet 4.6$3.000$15.00$0.02250$22.50Verified · Anthropic docs
Claude Opus 4.7 / 4.8 ²$5.000$25.00$0.03750$37.50Verified · Anthropic docs
Claude Fable 5 ²$10.000$50.00$0.07500$75.00Verified · Anthropic docs
Claude Mythos 5 ²$10.000$50.00$0.07500$75.00Verified · Anthropic docs · limited availability
OpenAI GPT-4o-mini$0.150$0.60$0.00105$1.05Verified (Jan 2026)
OpenAI GPT-4o$2.500$10.00$0.01750$17.50Verified (Jan 2026)
Gemini 3.5 Flash (unverified)$1.500$9.00$0.01200$12.00Cannot confirm model exists
Gemini 3.1 Pro (unverified)$2.000$12.00$0.01600$16.00Cannot confirm model exists
DeepSeek-V4-Flash (unverified)$0.140$0.28$0.00084$0.84Rates change frequently
DeepSeek-V4-Pro (unverified)$0.435$0.87$0.00261$2.61Rates change frequently

¹ Gemini 2.5 Flash base price corrected from stale $0.075/M. Google published $0.30/M for text input (paid tier) as of July 2026.

² Uses the newer Anthropic tokenizer - see tokenizer footnote above.


5. Pricing with Caching Enabled (4,500 cached / 500 fresh input / 500 output)

[!TIP] Cache-hit steady state assumed - the cache-write cost (Anthropic 1.25× first turn) is amortised across many reads. Storage cost included where applicable.

ModelCache hit rateCache read $/MCached inputFresh inputOutputStorage/hr*Per turnPer 1,000 turns
Claude Haiku 4.590% off$0.100$0.00045$0.00050$0.00250-$0.00345$3.45
Gemini 2.5 Flash (implicit)90% off$0.030$0.000135$0.00015$0.00125-$0.00154$1.54
Gemini 2.5 Flash (explicit)90% off$0.030$0.000135$0.00015$0.00125$0.0014see note †see note †
Gemini 2.5 Pro90% off$0.125$0.000563$0.000625$0.00250$0.0063$0.00369 + storageTraffic-dependent
Claude Sonnet 5 (intro)90% off$0.200$0.00090$0.00100$0.00500-$0.00690$6.90
Claude Sonnet 5 (standard)90% off$0.300$0.00135$0.00150$0.00750-$0.01035$10.35
Claude Opus 4.7 / 4.890% off$0.500$0.00225$0.00250$0.01250-$0.01725$17.25
Claude Fable 590% off$1.000$0.00450$0.00500$0.02500-$0.03450$34.50
Claude Mythos 590% off$1.000$0.00450$0.00500$0.02500-$0.03450$34.50
OpenAI GPT-4o-mini50% off$0.075$0.00034$0.00008$0.00030-$0.00072$0.72
OpenAI GPT-4o50% off$1.250$0.00563$0.00125$0.00500-$0.01188$11.88
DeepSeek-V4-Flash (unverified)~90% off$0.014$0.00006$0.00007$0.00014-$0.00027$0.27
DeepSeek-V4-Pro (unverified)~90% off$0.044$0.00020$0.00022$0.00044-$0.00086$0.86

* Gemini storage cost is per hour of cache lifetime, independent of read count. Amortised across reads. † Gemini 2.5 Flash explicit-cache cost per 1,000 turns depends on read rate. At 1 turn/hour storage dominates and cached turns cost more than uncached; at 100 turns/hour storage is negligible. Implicit caching has no storage fee and is the operationally correct choice for 2.5-flash.