Credits & billing
Credit ledger
Balances live in credit_balances; every movement is recorded in credit_transactions.
| Type | Meaning |
|---|---|
grant / topup | Add credits |
debit | Job completed |
refund | Job failed / cancelled |
monthly_reset | Allowance top-up |
Reserve moves credits from available → reserved at submit. Finalize debits or refunds.
Plans
| Plan | Generation credits / month |
|---|---|
| free | 500 |
| pro | 3,000 |
| team | 10,000 |
Plan changes sync allowance via sync_org_generation_credits_for_plan (service role / internal RPC only).
Billing providers
billingProvider | Checkout |
|---|---|
mock | In-memory + update_organization_plan (local only, gated) |
stripe | Stripe Checkout + webhooks |
custom | Your Edge webhook → apply_billing_subscription |
UI uses BillingPort — no payment SDK in features.
Web app adapter
WebBillingAdapter merges Postgres billing snapshot with mock plan metadata for display. Stripe paths invoke Edge functions; mock paths sync plan to Postgres after checkout.
See Custom provider and Monthly reset.
Last updated on