Transparent Engineering Methodology
How Costs, Caching & Batch Rules Are Calculated
Every calculation runs deterministically in browser memory against versioned USD list rates verified directly from official provider documentation on 2026-11-12.
1. Context Tier & Long-Context Cliff Resolution
Providers such as OpenAI (>272K input tokens), Anthropic Haiku 5.5 (>100K total input tokens), and Google Gemini 3.1 Pro (>200K prompt tokens) apply step-function rate jumps to the entire request once input exceeds the threshold. Our engine resolves totalTurnInput = prefixTokens + dynamicInputTokens against sorted pricingTiers and flags EXCEEDS_CONTEXT_WINDOW if input exceeds maxInputTokens ?? contextWindowTokens.
2. Prompt Caching Amortization (Zero Double-Counting)
Instead of charging an arbitrary one-request penalty, cold cache writes are amortized across daily active hours H_active (16 hrs/day interactive, 24 hrs/day batch):
writeReqs = cacheActive ? min(requestsPerDay, cacheWritesPerHour * H_active) : 0 missReqs = max(0, requestsPerDay * (1 - cacheHitRate) - writeReqs) hitReqs = max(0, requestsPerDay - writeReqs - missReqs) dailyPrefixCost = (hitReqs * prefixM * r_read) + (missReqs * prefixM * r_in) + (writeReqs * prefixM * r_write)
If prefixTokens < minCacheableTokens (e.g., 512 on Claude 5.x, 1,024 on OpenAI GPT-6.x, 4,096 on Gemini), caching is automatically disabled to reflect silent fallback to standard input billing. Explicit hourly cache storage (e.g., Gemini storagePer1MPerHour) is added un-discounted across H_active.
3. Three-State Batch + Caching Rules
- Stacks with Batch Discount: Anthropic Message Batches, OpenAI Batch (GPT-5+), and Gemini 3.8 Flash / 4 Carbon discount both uncached and cached token reads.
- Allowed at Standard Cache Rates: Gemini 3.1 Pro Preview allows caching in Batch mode, but bills cached reads and storage at standard rates while discounting uncached tokens 50%.
- Disallowed / 0% Discount: Groq & Amazon Bedrock disable prompt caching in Batch mode; Together AI applies 0% batch discount to serverless chat models; DeepSeek has no Batch API (offering a 50% Off-Peak UTC window instead).
4. Multi-Turn Quadratic History Scaling
For multi-turn sessions of K turns (such as the support-agent preset with K = 5), turn t re-sends all prior user prompts and assistant replies. The engine evaluates each turn t = 1..K individually via:
totalInput(t) = prefixTokens + turn1UserTokens + (t - 1) * (followUpUserTokens + outputTokens)