Skip to main content
Metering is the cross-cutting backbone — every AI action writes here. See the concept guide on metering & credits for the flow.

Metering (metering app)

ModelPurposeNotes
UsageEventOne record per AI actionImmutable. provider, model, tokens, credits, cost_usd (real cost), byok flag. Indexed on (org, ts).
CreditWalletPer-org credit balance1:1 Organization. Tracks balance + reserved.
CreditTransactionLedger entryImmutable. kindGRANT · TOPUP · SPEND · REFUND.
RateCardPer-feature preflight pricecredits_per_unit, optional per-model multipliers.
AICredentialSelf-host provider key storageEncrypted; used by the self-host/Community edition, not hosted BYOK.

Billing (billing app)

ModelPurpose
BillingPlanSubscription tier (price, included monthly credits, limits, Stripe price id)
CreditPackOne-time credit top-up (Stripe price id)
SubscriptionOrg → plan (status, Stripe subscription id, period)

Why this is trustworthy

UsageEvent.cost_usd records the real provider cost, so manage.py check_margins can prove that no feature is billed below cost and audit gross margin across both LLM and paid-data spend.
Generated from the metering and billing app models; re-syncs each iteration.