Retry cost is double-counted or omitted
Detect: Ledger totals diverge from attempt records.
Recover: Use unique usage-event IDs and explicit retry relationships.
Attribute inference usage to the business work that caused it, including retries, caches, tools, and shared infrastructure.
Token cost allocation maps model usage to a tenant, team, workflow, or product feature. It requires more than multiplying a final response’s token count by a price: retries, planning calls, embedding requests, cache reads or writes, multimodal inputs, and failed attempts can all contribute. Self-hosted inference also needs infrastructure cost allocation rather than provider token billing alone.
The accounting system should distinguish estimated usage at admission from observed usage and reconciled billing. Prices and billing categories vary by provider, model, region, and contract, so a versioned rate catalog is essential. Allocation is an operational and financial measurement system; it should not expose sensitive prompt contents merely to identify ownership.
A prototype tags every model call with a workflow and feature identifier and compares estimates with returned usage.
Production records attempt-level usage, rate versions, cache categories, and unattributed cost exceptions.
Enterprise scale reconciles invoices, allocates shared capacity with documented rules, and connects budgets to admission without silently blocking essential workflows.
Carries tenant, feature, workflow, and attempt identifiers through inference calls.
Normalizes model-specific reported usage while preserving original categories.
Stores effective prices and contractual dimensions by date and model.
Records immutable estimated, observed, and reconciled amounts.
Aggregates ownership and informs quotas, alerts, and capacity decisions.
flowchart LR
W["Workflow cost identity"] --> A["Model and embedding attempts"]
A --> U["Observed usage events"]
R["Versioned rate catalog"] --> L["Cost ledger"]
U --> L
L --> C["Tenant and feature allocation"]
B["Provider bill or infrastructure cost"] --> X["Reconciliation"]
L --> X
X --> CAttach a stable cost center and workflow identity before any model or embedding call.
Use input size and output limits to reserve an approximate budget.
Capture provider, model, usage categories, cache behavior, and retry relationships.
Calculate observed cost using the rate effective for the actual usage event.
Compare the ledger with provider billing or infrastructure allocation and investigate differences.
Include failures and retries when comparing routes or product features.
Enterprise collaboration · Illustrative enterprise scenario, not a reported customer outcome.
A collaboration platform offers document summaries, meeting follow-ups, and workspace search to several business units.
Shared provider invoices cannot explain which features generate retries or expensive long-context work.
Attribute complete accepted-task cost without logging private document text.
Usage envelopes connect every inference attempt to feature and business-unit identifiers, and a ledger applies effective rates.
If a provider omits final usage after a broken stream, the ledger retains an estimate and marks it pending reconciliation.
Measure unattributed spend, reconciliation variance, and cost per accepted task; a low reported average is misleading when failed attempts are excluded.
| Decision | Benefit | Cost |
|---|---|---|
| Fine-grained attribution | Reveals costly workflow stages. | Increases event volume and ownership metadata management. |
| Admission estimates | Support proactive budget control. | Differ from actual generation and billing. |
| Shared infrastructure allocation | Enables self-hosted chargeback. | Requires an agreed rule for idle and reserved capacity. |
Detect: Ledger totals diverge from attempt records.
Recover: Use unique usage-event IDs and explicit retry relationships.
Detect: Historical reports change unexpectedly.
Recover: Apply effective-dated rates and immutable reconciled entries.
Include all attempts and supporting model work.
Use a versioned provider and contract rate catalog.
Account for idle, storage, network, and accelerator allocation where relevant.