Skip to main content
Build a multi-tenant AI platform where each client gets their own branded experience with automatic per-user billing. No Stripe metering code required.

What You’ll Build

A platform that:
  • Serves multiple clients/organizations
  • Enforces per-user and per-organization budgets
  • Tracks usage automatically
  • Bills based on actual consumption
  • Requires zero custom metering code

Architecture

How Budget Enforcement Works

  1. Your server creates JWT tokens with embedded budgets
  2. Chucky validates tokens and tracks usage
  3. When budget depletes, requests are rejected
  4. Usage data returned with each response
No database queries. No usage counters. No race conditions. Budget enforcement happens at the edge.

Implementation

1. Define Subscription Tiers

2. Token Generation Endpoint

3. Client Integration

4. Usage Tracking (Optional)

Track usage for your dashboard:

Multi-Tenancy Patterns

Per-Organization Projects

Each client gets their own Chucky project:

Shared Project with User Isolation

All clients share one project, isolated by userId:

Custom Workspaces per Client

Each client has their own codebase:

Handling Budget Exceeded

Usage Dashboard

Build a dashboard showing:

Pricing Your Platform

Cost-Plus Model

Usage-Based Add-on

Best Practices

1. Short-Lived Tokens

2. Graceful Degradation

3. Audit Logging

4. Rate Limiting

Even with budget limits, add rate limiting:

Next Steps

Authentication

Deep dive into token creation

Budget Management

Advanced budget strategies

Error Handling

Handle errors gracefully

Billing

Understanding costs