AI API billing reconciliation
Record the AI usage your application actually caused, make delivery retries idempotent, retain accepted events, and compare your own monthly quantities with the provider bill instead of treating a vendor dashboard as the only ledger.
Meter tokens when token quantity is the stable source signal. If your application already computes a per-request or per-task cost, meter that numeric value instead. UsageBox stores what you send; it does not invent provider pricing.
Use the customer subscription ingest key and the meter or product-item stream you configured. A provider invoice can tell you the total vendor charge, but it cannot reconstruct customer attribution you never recorded.
A retry of the same logical usage event should reuse the same idempotency key. That keeps network behavior from becoming extra measured usage before you compare totals.
Monthly rollups are the compact comparison surface. Raw accepted events remain available when a discrepancy needs to be explained at event level rather than waved away as a dashboard mismatch.
Provider list prices, cache discounts, credits and negotiated rates change. Keeping those pricing rules outside the quantity record means historical usage does not change when the rate card does.
Gemini, Claude, OpenAI and other providers expose different billing views. Your own application can still report usage to one independent contract, which makes multi-provider reconciliation less dependent on provider-specific dashboards.
Implementation pattern
The request identifies the customer subscription and configured AI usage stream. Keep the same idempotency key only when retrying this same logical event.
If you also need monetary attribution, compute the cost in your application from the provider/rate information you trust and meter that value on a separate configured stream.
curl -X POST 'https://api.usagebox.com/api/v1/usage' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-H "Idempotency-Key: $(uuidgen)" \
-d '[{"subscription":"sub_customer-acme-...","product_item":"item_ai-api-...","meter":"meter_tokens-...","value":1842}]'Product boundary
UsageBox is the independent quantity ledger. It does not scrape Gemini, Claude, OpenAI, Cursor or another vendor account, and it does not promise that its quantity equals a provider bill unless your own instrumentation and pricing inputs define the same billable event.
Choose the usage signal, inspect the exact payload, then create a free key only when the contract fits your integration.