Metrune engineering

How to attribute token cost by customer and feature

A clean metadata model for turning provider usage into product-level unit economics and actionable budgets.

6 min readCost / Analytics

A provider invoice explains total spend but not which product decision created it. Cost becomes operational when every model request inherits the application context needed to assign it to a customer, feature, agent, and release.

Attach context at run creation

Add stable identifiers such as tenant, workspace, product surface, agent, environment, and release to the parent run. Propagate them to every downstream model call instead of rebuilding attribution later.

Normalize provider usage

Record input, output, cached, and reasoning tokens separately where supported. Apply a versioned price table so historical reports remain consistent when provider pricing changes.

Watch cost per outcome

Total spend grows with adoption. Cost per successful resolution, generated report, or completed workflow is usually a better health metric because it reveals inefficient retries and overlong context.

Put budgets near ownership

Define budgets at the level a team can act on: an environment, workload, customer group, or feature. Alerts should include the runs driving the change, not only a percentage threshold.