Skip to content

Cost attribution

Definition

Cost attribution is the gateway's computation and recording of the cost of every inference request, per tenant, gateway, token, user and model. The result feeds budgets, the spend ledger and cost analytics.

Function

Cost attribution makes spend visible and enforceable: every request carries a cost, and every budget is checked against the sum of those costs.

Cost calculation formula

The cost of one provider call is the sum of its token terms, each priced per 1,000 tokens, multiplied by a service-tier factor:

cost = ( input_tokens       × input price
       + output_tokens      × output price
       + cache-write tokens × cache-write price
       + cache-read tokens  × cache-read price ) / 1000
       × tier multiplier
  • Token counts come from the provider response. Reasoning ("thinking") tokens count as output tokens.
  • The cache terms apply only to providers that report prompt-caching tokens; otherwise they are zero.
  • The tier multiplier reflects the provider's service tier (for example batch or priority). An unknown tier counts as standard.
  • A request that makes several provider rounds (a tool loop, an auto-continuation) costs the sum of all rounds. Each round is one leg in the per-leg ledger.
  • The gateway's own inner model calls (conversation compaction, the inner call of agentic web fetch) are billed as their own legs.
  • When a client disconnects or the user stops an answer, the output already produced is still billed.

Prices

A price comes from the Model prices table first, and from built-in fallback prices when the table has no entry. A model with no known price is routed, but its requests are not counted against budgets.

Raw cost and charged cost

  • Raw cost is what the provider call actually cost. Request logs, the per-leg ledger, cost analytics and the cost response headers report raw cost.
  • Charged cost is what budgets and the wallet consume. For an external model on Myra's key it is the raw cost plus a markup; Myra self-hosted models, sidecar meter legs and calls on the workspace's own provider key are never marked up. A call on the workspace's own key is billed by the provider directly, so its charged cost is 0: neither the wallet nor any budget limit counts it (the per-agent monthly spend cap, which counts raw cost, is the exception). Its raw cost still appears in the request logs and cost analytics.

External-provider markup

The markup is a percentage per external model, set by a platform administrator, with a regional default. A missing or malformed markup falls back to the default; it can never zero a cost. See Provider costs.

Rules and facts

  • Costs are stored and enforced in USD. The interface shows them in the viewer's display currency.

See also