Welcome to Nebutra Sailor Docs 🎉
ChangelogIntroductionLicensing
Help Center (External) ↗

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, web3 features

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.completedProvision plan, send welcome email
customer.subscription.updatedUpdate tenant plan and quotas
customer.subscription.deletedDowngrade to FREE
invoice.payment_failedSend payment failure email
invoice.paidLog payment, update billing period
Creem event (current, one-time card purchases)Action
checkout.completedSettles the payment order (pre-tax amount vs. locked offer price)

Related

Rate Limits

How rate limit headers work and how to handle 429 responses.

Creem Integration

The current card rail — worldwide, merchant of record.

Stripe Integration (legacy)

Subscriptions, billing portal, and pre-switch checkouts.

How is this guide?

Edit on GitHub

Last updated on

On this page

Plans
How metering works
Quota enforcement
Quota query
Payment providers
Related