Billing Model
The three-tier plan structure shipped in @nebutra/billing's default config, usage metering, and how quotas are enforced.
Plans
@nebutra/billing ships DEFAULT_PLAN_LIMITS and DEFAULT_PRICING for three tiers
(packages/commerce/billing/src/types.ts) — a starting default, not a fixed product; edit the
config to rename, reprice, or add features.
FREE
$0/month
- 1 team member
- 1 project
- 1,000 API calls/month
- 10,000 AI tokens/month
- 100MB storage
PRO
$29/month
- Up to 10 team members
- 10 projects
- 50,000 API calls/month
- 500,000 AI tokens/month
- 10GB storage
ENTERPRISE
Contact sales
- Unlimited members, projects, API calls, AI tokens, storage
sso,audit_logs,priority_support,custom_models,web3features
How metering works
Usage is tracked via @nebutra/metering, provider-agnostic: ClickHouse in production, in-memory
in dev/test. Standard meters ship pre-defined (API_CALLS, AI_TOKENS, STORAGE_BYTES,
BANDWIDTH, and others in ALL_STANDARD_METERS); define your own if you need a metric the
standard set doesn't cover.
import { getMetering, API_CALLS } from "@nebutra/metering";
const metering = await getMetering(); // auto-detects the provider
await metering.defineMeter(API_CALLS);
await metering.ingest({
meterId: "api_calls",
tenantId: "org_123",
value: 1,
properties: { endpoint: "/api/v1/ai/chat", method: "POST" },
});Quota enforcement
evaluateUsageLimit (from @nebutra/metering) checks a tenant's usage against its plan limit —
wire it into a gateway middleware to enforce it before business logic runs. The FEATURE_DISABLED
/ QUOTA_EXCEEDED codes and the error envelope come from @nebutra/errors — see
Error Reference for the exact shape:
{
"error": {
"code": "QUOTA_EXCEEDED",
"message": "Monthly API call quota exceeded.",
"details": { "limit": 1000, "used": 1001 }
},
"requestId": "req_..."
}Quota query
const metering = await getMetering();
const quota = await metering.getQuota("org_123", "api_calls", "monthly");
// → { meterId, tenantId, limit, used, remaining, percentage, period, periodStart, periodEnd }Payment providers
Per ADR 2026-09-26, one-time card purchases (e.g. plan upgrades bought outright, credit top-ups) go through Creem — cards worldwide, merchant of record — alongside WeChat Pay / Alipay for mainland China. The recurring plan subscription described above still runs on Stripe today (legacy): nothing new is built on it, and it stays only until subscriptions move to Creem subscriptions (subscription.* events).
The API gateway includes pre-built webhook handlers for both:
| Stripe event (legacy, subscriptions) | Action |
|---|---|
checkout.session.completed | Provision plan, send welcome email |
customer.subscription.updated | Update tenant plan and quotas |
customer.subscription.deleted | Downgrade to FREE |
invoice.payment_failed | Send payment failure email |
invoice.paid | Log payment, update billing period |
| Creem event (current, one-time card purchases) | Action |
|---|---|
checkout.completed | Settles the payment order (pre-tax amount vs. locked offer price) |
Related
How is this guide?
Last updated on