$0LLM Cost IntelligenceClient-Side FinOps & Token Budgeting

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)

5. Verified Model Source Citations (20 Entries)

ModelHostVerifiedOfficial Documentation URL
GPT-6 AstraOpenAI First-Party2026-11-12https://developers.openai.com/api/docs/pricing
GPT-6.1 SolOpenAI First-Party2026-11-12https://developers.openai.com/api/docs/pricing
GPT-6 LunaOpenAI First-Party2026-11-12https://developers.openai.com/api/docs/pricing
Claude Fable 5.2Anthropic First-Party2026-11-12https://platform.claude.com/docs/en/about-claude/pricing
Claude Sonnet 5.5Anthropic First-Party2026-11-12https://platform.claude.com/docs/en/about-claude/pricing
Claude Haiku 5.5Anthropic First-Party2026-11-12https://platform.claude.com/docs/en/about-claude/pricing
Gemini 4 CarbonGoogle AI Studio / Gemini API2026-11-12https://aistudio.google.com/docs/pricing
Gemini 3.8 FlashGoogle AI Studio / Gemini API2026-11-12https://aistudio.google.com/docs/pricing
Gemini 3.1 Pro PreviewGoogle AI Studio / Gemini API2026-11-12https://aistudio.google.com/docs/pricing
DeepSeek Flash (V4.1-Flash-1017)DeepSeek First-Party2026-11-12https://api-docs.deepseek.com/quick_start/pricing
DeepSeek V4 Pro (0813)DeepSeek First-Party2026-11-12https://api-docs.deepseek.com/quick_start/pricing
Mistral Large 4Mistral La Plateforme2026-11-12https://docs.mistral.ai/inference/pricing
Mistral Small 4 (2603)Mistral La Plateforme2026-11-12https://docs.mistral.ai/inference/pricing
GPT-OSS 120B (Groq)Groq LPU2026-11-12https://console.groq.com/docs/models
Qwen3.8 27B Preview (Groq)Groq LPU2026-11-12https://console.groq.com/docs/models
DeepSeek V4.1 Flash (Together AI)Together AI Serverless (FP8)2026-11-12https://docs.together.ai/docs/serverless/models
GPT-OSS 120B (Together AI)Together AI Serverless (MXFP4)2026-11-12https://docs.together.ai/docs/serverless/models
Claude Sonnet 5.5 (Amazon Bedrock)Amazon Bedrock (Cross-Region Inference)2026-11-12https://aws.amazon.com/bedrock/pricing/
GPT-OSS 120B (Amazon Bedrock)Amazon Bedrock (US Regions)2026-11-12https://aws.amazon.com/bedrock/pricing/
Llama 4 Maverick 17B (Amazon Bedrock)Amazon Bedrock (US Regions)2026-11-12https://aws.amazon.com/bedrock/pricing/