- AI and agent products metered by tokens, calls, or seconds
- Pay-as-you-go APIs where customers fund a balance and draw it down
- Any product where you want the customer to watch their balance decrease live
Real-time billing is wallet-backed: it reuses the same prepaid wallet, pause-on-empty, and auto-resume-on-top-up machinery as Prepaid Billing. The difference is when the wallet is debited — continuously, rather than once at period end.
For a complete, copy-paste integration walkthrough using an AI agent as the example — customer creation, metric, plan, wallet widget, and event ingestion — see the AI Prepaid Wallet guide. This page focuses on the billing mode itself.
How it works
Charging is asynchronous and batched, so it never sits on your ingest hot path. The wallet’s double-entry ledger is the system of record throughout; the period-end invoice is just a record of what was already debited.Setting up a real-time plan
Set"billing_mode": "realtime" and attach prices for your metrics:
Wallet auto-creation
Real-time billing debits a prepaid wallet, so the customer needs one funded in the plan’s currency. As with prepaid plans, Monigo creates the wallet automatically when the customer subscribes if one doesn’t already exist. Let the customer fund it inline with the<WalletWidget> component (React, Svelte, or Vue), which shows the live balance and opens the provider’s checkout on Top up. See Wallet Management and Embedding the Portal.
The reconcile engine
Each flush cycle does not price individual events. Instead it reconciles: it recomputes the cost of all usage so far this period and debits only the difference since the last charge.- Tiered, package, and overage pricing stay exact across the whole period, because the cost is always recomputed from the cumulative quantity — never summed from per-event slices that would land in the wrong tier.
cappricing charges its flat fee exactly once: the first reconcile debits the base price, and every subsequent reconcile computes a marginal of zero.
- ~5 second latency. Charging trails ingestion by roughly the flush interval. It’s asynchronous, so it never blocks event ingestion.
- Crash-safe and idempotent. Each debit carries a deterministic idempotency key derived from the charge sequence, so a retry after a crash can never double-charge.
- Bounded free usage. Because charging trails ingestion by a few seconds, a small amount of usage can be metered in the window between the balance hitting zero and the pause taking effect. This is bounded to roughly one charge interval.
Handling insufficient balance
When the wallet can’t cover the next marginal charge, Monigo:- Pauses the subscription and blocks further usage events for that customer (so usage can’t run up unbilled while the balance is empty).
- Fires a
subscription.prepaid_balance_insufficientwebhook.
subscription.prepaid_balance_insufficient
Auto-resume on top-up
When you credit a wallet belonging to a customer with a paused real-time subscription, Monigo automatically:- Reactivates the subscription
- Charges any usage that accrued but went unbilled while the balance was empty (the residual)
- Unblocks further events and resumes continuous debiting
What happens at period end
The money has already been debited continuously, so the period close is just bookkeeping. At month end Monigo emits one paid summary invoice — per-metric line items, total equal to what was actually debited — and no additional charge is made. The invoice exists for the customer’s records, then the period advances. This is the key difference from prepaid: prepaid does all its work at period end (one debit, one invoice), while real-time has done the debiting throughout and uses period end only to issue the summary.Webhook events
Register a webhook endpoint in the Webhooks guide to receive these events.
Customer portal
In the customer portal, a real-time subscription shows the customer their live wallet balance drawing down as usage accrues, alongside a Top up wallet → action. The monthly summary invoice appears under their invoices once the period closes. This gives customers continuous visibility into exactly what they’re spending.Comparing the billing modes
Related
- AI Prepaid Wallet — full end-to-end integration walkthrough
- Prepaid Billing — wallet debited once at period end
- Postpaid Billing — the default, collected via payment provider
- Wallet Management — wallet operations and the
<WalletWidget> - Pricing Models — tiered, package, overage, and cap pricing
- Webhooks — receiving billing events

