Record one event after each model call and include the structured _llm metadata. A meter can aggregate metadata._llm.total_tokens, input_tokens, or output_tokens, while Cost Insights reads the optional _cost object. Use a stable external_id for retries. If the same event is sent again, OurPay counts it as a duplicate instead of billing the customer twice.

TypeScript

Python

_cost.amount is expressed in cents and can be fractional for very small costs. For example, 123 is US1.23and0.025isUS1.23 and `0.025` is US0.00025.
Send the event only after the model provider returns final usage totals. Streaming applications should ingest once when the stream closes, not once per chunk.