The problem with estimating twice
Most LLM cost reporting is built backwards. Requests run all month, usage is exported afterwards, and a dashboard estimates what the traffic must have cost. Then the provider invoice arrives, estimated differently, and the two numbers disagree by an amount nobody can decompose — because the detail needed to check either of them (the token mix of each individual request) was never recorded.
Settle at completion
The alternative is to treat cost as a property of the request, settled at the moment it completes:
- Separate the request's tokens into disjoint buckets — uncached input, output, cache creation (5-minute and 1-hour), cache read, and reasoning tokens. The classes are priced differently, so a single total cannot reproduce the charge.
- Apply the exact published list-price rate card once. This taxonomy follows the FinOps FOCUS 1.4 specification.
- Write the settled figure to a ledger. Dashboards, exports, and API responses then read from the ledger instead of recalculating.
A daily parity check between reported spend and the ledger turns "the numbers look close" into a pass/fail property.
Attribution is a request-time decision
Which team, project, feature, or customer a request belongs to is known only when the call is made. Passing tags with the request (through the standard metadata field) attaches that context to the settled record, so spend can later be rolled up by any tag combination. Retrofitting attribution from logs a month later is guesswork.
Latency in the same record
The settled record also carries timing: time-to-first-token separately from total duration, and p50/p95/p99 percentiles per model, key, and tag. When a percentile or a spend chart spikes, the view drills through to the underlying requests — the same records the chart summed.
Summary
Settle once, tag at the call site, and let every report read from the settled record. That is the design of nRouter Analytics: real-time spend, token, and latency reporting, with CSV export for BI tools and a response header (x-nr-request-cost) that matches the ledger exactly.