Billing
What gets metered
Section titled “What gets metered”| Resource | Unit | Notes |
|---|---|---|
| Runtime instance | seconds running | Charged at the tenant’s plan rate. |
| LLM tokens (BYOK) | passed-through | cloudscode does not mark up tokens; you pay your provider directly. |
| Outbound webhooks | per delivery | Cheap; included in most plans. |
| Storage | GB-month | Conversation history, replays, audit. |
| Egress bandwidth | GB | Plan-dependent. |
Plans are stored in the plans table and referenced by name on each tenant. A plan defines:
- monthly base credit allotment,
- per-resource rates above that allotment,
- concurrency limits (max concurrent instances, max requests/sec),
- feature flags (e.g. team SSO, audit-log export).
Credits
Section titled “Credits”Tenants spend credits, not currency. Credits are minted when a tenant tops up (whatever your processor) and consumed as resources run. The credit ledger is append-only and reconcilable.
curl -sS http://localhost:8787/credits \ -H "x-tenant-id: <tenant_id>"# => { "balance": 12500, "currency": "credits", "as_of": "2026-04-29T12:00:00Z" }Pluggable processor
Section titled “Pluggable processor”To wire a real processor (Stripe, Paddle, a manual invoice flow, …), implement the BillingProcessor interface in apps/api/src/lib/billing/. The interface is small: topUp, refund, webhook. See the source for the canonical contract.