Book a demo
Topics · AI-CONTROL-PLANE

SaaS AI Gateway Cost Per Case | Moring

Cost per case is the unit-economics metric a SaaS platform needs for AI features: what one resolved support ticket, one processed document, or one completed agent workflow actually costs in model, tool, and retry spend. Because an LLM request maps to no predictable unit of work, cost depends on model choice, prompt size, output length, retries, tool calls, and provider token accounting, so per-case figures only become reliable when the gateway attaches trusted identity, reserves budget, settles actual token usage, and logs each request. With accurate per-request costs, per-case margins become governable through routing, caching, and budgets enforced where the traffic flows.

On this page
  1. Short answer
  2. How it works
  3. FAQs
  4. Related reading
  5. Sources

Short answer

Cost per case is the unit-economics metric a SaaS platform needs for AI features: what one resolved support ticket, one processed document, or one completed agent workflow actually costs in model, tool, and retry spend. Because an LLM request maps to no predictable unit of work, cost depends on model choice, prompt size, output length, retries, tool calls, and provider token accounting, so per-case figures only become reliable when the gateway attaches trusted identity, reserves budget, settles actual token usage, and logs each request. With accurate per-request costs, per-case margins become governable through routing, caching, and budgets enforced where the traffic flows.

How it works

Cost per case is the discipline of attributing AI spend to the business unit of work a SaaS platform actually sells: a resolved support conversation, a summarized document, a completed agent workflow, or a code task. The difficulty is fundamental to how LLMs bill. Unlike a conventional API request, an LLM request does not map neatly to a predictable unit of work; cost depends on the selected model, prompt size, generated output, retries, tool calls, and provider-specific token accounting, and provider dashboards are usually retrospective. A SaaS team that cannot decompose that variability into per-case figures is running AI features with an unknown margin per interaction, which is unsustainable in a business defined by unit economics.

The gateway is the natural place to compute the figure because every request already passes through it. The gateway can attach trusted identity, reserve budget capacity, record actual token usage, and reject calls when an allocation is exhausted, following a four-step design: validate the caller and overwrite trusted identity headers, reserve estimated budget before the request leaves, settle the reservation using provider-reported token usage, and alert, forecast, and optimize using real spend data. Reference implementations of this pattern add hierarchical budgets, pre-request reservations, actual-cost settlement, forecasting, approvals, rate limits, and a management UI. Once per-request cost is accurate and attributable, per-case cost is an aggregation, not an estimate.

Accuracy matters more here than for aggregate reporting, and gateways increasingly match what providers actually bill. Cost is one of the primary signals AI governance acts on: budget enforcement, per-consumer spend limits, and chargeback all depend on an accurate cost figure for each request, calculated for every LLM provider call to match what the provider bills. The pricing dimensions are non-obvious and materially change per-case figures: cache reads are priced separately from input, with a hit typically discounted to around one tenth of the input rate, cache writes can cost more than a normal input token, cache lifetime tiers change pricing, for example a provider pricing a 5-minute TTL at 1.25 times input and a 1-hour TTL at 2 times, and context-size thresholds re-price an entire request at a higher rate once input tokens cross a boundary. A SaaS feature whose prompts frequently cross a context threshold can double in per-case cost without any code change, which is why governance must enforce against a figure that reflects real provider spend.

The motivation for per-case rigor is visible in the industry's cost stories. Enterprises are dealing with a dilemma of enabling AI-driven innovation at reasonable costs while visibility is low and costs spiral; use cases have moved from simple generation to code generation and agents, increasing spending compared with earlier applications. Public examples include a CTO who reported spending an entire quarterly IT budget of 26 million dollars on AI compute in one quarter and having to figure out how to fund the rest of the year, alongside widely reported cancellations of AI licenses and usage-leaderboard programs citing improper use. For a SaaS platform, an unmonitored agent loop or evaluation pipeline is the same failure at smaller scale, and it surfaces first in per-case cost, where a case count that stays flat while spend doubles is an immediate signal.

Cost control needs something to attach to, and that is the structural insight behind per-case accounting. A warehouse is an object that can be sized, suspended, and budgeted, while a coding agent on someone's laptop is not, until the gateway gives AI traffic a governed entry point that every request passes through, with a single place to decide which roles may spend, record what each request cost, enforce a limit once crossed, and bound which models callers reach. Per-consumer spend limits and chargeback follow naturally, letting a SaaS platform treat internal AI consumption the way it treats infrastructure, and treat product-side AI per-case cost the way it treats any other cost of goods.

Per-case figures also drive the routing decisions that keep cases affordable. Every SaaS product shipping AI features talks to one or more AI model providers, and that traffic needs to be managed: gateways are the infrastructure layer that handles routing, cost control, authentication, caching, and observability for AI traffic. Picking the wrong arrangement produces runaway costs, blind spots in production, and painful migrations, while the right one gives a control plane that scales from prototype to production, and with per-request costs flowing into routing analytics, a SaaS team can route each case to an economical model that meets its quality bar instead of defaulting every request to the most expensive one.

The practical takeaway for SaaS operators is to define the case for each AI feature, instrument the gateway to settle actual token costs per request, aggregate into per-case dashboards by feature and customer tier, and set budgets and alerts at the case level, so an anomalous cost per case triggers review before the next invoice rather than after it. Per-case cost then becomes what it should be in a SaaS business: a governed unit-economic metric, not an anecdote.

Frequently asked questions

How does a SaaS AI gateway calculate cost per case?

The gateway records an accurate cost figure for every LLM request, matching what the provider bills, by computing input and output token rates plus dimensions such as cache reads and writes, cache lifetime tiers, and context-size thresholds, then settles estimates with provider-reported usage. Per-case cost is the aggregation of those request costs by feature, ticket, or workflow, attributed to the caller identity the gateway validated. This turns an unpredictable provider invoice into a governed unit-economic metric.

Why is per-request cost accuracy critical for per-case figures?

Because pricing dimensions are easy to miss: cache reads are discounted to roughly a tenth of the input rate while cache writes can exceed normal input pricing, cache TTL tiers change rates, and context-size thresholds re-price an entire request at a higher rate once input tokens cross a boundary. A feature whose prompts cross such a threshold can double per-case cost with no code change. Governance policies enforcing budgets must act on a figure that reflects real provider spend, or limits fail silently.

What cost signals warn a SaaS team about runaway AI spend?

The earliest signals live in the gateway: per-case cost rising while case counts stay flat, reservations failing as budgets exhaust, retries or fallbacks multiplying token usage, and requests defaulting to more expensive models after routing changes. Industry examples show the cost of missing them, including a CTO who spent an entire quarterly IT budget on AI compute in one quarter. Gateway alerts on these signals trigger review before the next provider invoice arrives.

How does per-case cost data drive AI feature routing in SaaS?

With per-request costs and performance flowing through one endpoint, teams can route each case to the best-fit model, using lightweight models for extraction and tagging and frontier models for synthesis, balancing quality and cost per stage. Gateways centralize fallbacks, retries, and rate limiting across providers, so routing decisions also account for throttling and degradation. The result is a per-case margin that is engineered through routing rather than accepted as a monthly surprise.

Sources

  1. - eur-lex.europa.eu