Record response metadata
For one call, metadata returned by that response is primary: id, usage, or cost only when the matching field is present.
Do not assume a separate aggregation endpoint: an external collector needs its own published contract.
Per-response request record
typescript
const requestRecord = {
model: selectedModel,
status: response.status,
responseId: responseBody.id,
usage: responseBody.usage ?? null,
receivedAt: new Date().toISOString(),
};
// Persist only usage fields actually returned by this response.Data model
- Separate input, output, cached, and media units when returned.
- Keep currency and unit of measure next to every number.
- Do not total unfinished background jobs as final spend.
Operational view
Build a dashboard around the product: users, workflows, models, errors, and latency. It exposes behavior changes earlier than one overall total.
Restrict access to usage data with the same rules used for financial or organizational information.