commercepackages/commerce/metering
metering package
Usage metering on ClickHouse — sub-second ingestion, per-tenant quota lookup, ready to feed Stripe metered billing or in-product limits.
- Stability
- Stable
- Scope
- Tenant-scoped
- Boundary
- packages/commerce/metering
@nebutra/metering
tenant_org_abc123Prolive
API calls
4,521
of 10,000
AI tokens
847K
of 2M
Storage
12 GB
of 50 GB
Active users
38
of 100
| Meter | Period usage | Cap | % used | Pricing tier |
|---|---|---|---|---|
| api_calls | 4,521 | 10,000 | Pro · $0.001/call | |
| ai_tokens | 847,000 | 2,000,000 | Pro · metered | |
| storage_bytes | 12,000,000,000 | 50,000,000,000 | Pro · 50 GB incl. | |
| active_seats | 38 | 100 | Pro · seat-based |
Usagemetering.ts
typescriptmetering.ts
1import { getMetering, createUsageEvent, COMMON_METERS } from "@nebutra/metering";
2
3const metering = await getMetering();
4
5await metering.ingest(
6 createUsageEvent(COMMON_METERS.API_CALLS.id, org.id, 1, {
7 endpoint: "/api/chat",
8 model: "claude-sonnet-4-6",
9 }),
10);
11
12const quota = await metering.getQuota(org.id, "api_calls");
13// → { limit: 10000, used: 4521, remaining: 5479, percentage: 0.4521 }