LEDGERMETER
billing core for AI SaaS — credits, metering, Stripe
connecting…
Credit balance
1 credit = 1 token · hard floor at 0
Purchased + granted
via Stripe checkout + seed grant
Burned
metered per token, per call
Burn rate · 30 min
0 cr/min

Run a metered AI call

Fake-AI endpoint bills like the real thing: tokens in + out → atomic credit decrement. Same requestId can hit 5× — you pay once.

// metering console — every call below hits the live ledger

Top up credits

Stripe Checkout (test mode) → signed webhook → ledger credit, deduplicated by event.id. Card 4242 4242 4242 4242 works.

50,000
Starter
$9
250,000
Pro
$29
1,000,000
Scale
$79
signature-verified webhook · retries never double-credit

Append-only ledger

Source of truth. No UPDATE, no DELETE — a Postgres trigger raises on both. Balance is derived, never edited by hand.

#timekindamountbalance afterref (idempotency key)meta
loading ledger…
APPEND-ONLY

Every movement is an immutable ledger row. Mutations blocked at the database layer by trigger.

EXACTLY-ONCE

UNIQUE(ref_id) turns at-least-once delivery — Stripe retries, client storms — into exactly-once billing.

ZERO DRIFT

Balance updates in the same transaction as the ledger insert. SUM(ledger) ⇄ balance verified on every poll.

OVERAGE GUARD

Row-level lock + balance check before charge. Concurrent calls can't spend credits that aren't there.