Handle partial AI usage records in spend reporting
Separate recorded usage, temporary estimates and missing fields. An interrupted or streamed request might only expose some measurements until a later report.
Example
A stream closes before its final usage event. The gateway has a request ID and elapsed time but no confirmed output token count.
What to do
- Record which fields are confirmed for every attempt. Keep the request and reporting timestamps.
- Use an explicit incomplete state. If estimates are needed, label them and preserve the original evidence.
- Reconcile later provider usage against the request ID where possible. Update the estimate once confirmed records arrive.
How to verify
Late records replace estimates without double-counting, and the dashboard distinguishes confirmed costs from incomplete ones.
Limits
Some providers do not supply item-level detail for all request types. Aggregate reconciliation may be the only available check.