
Multi-Tenant Architecture: 3 Models & 8 Best Practices
Learn how multi-tenant architecture works, compare database isolation models, and explore six components & eight best practices for shared infrastructure.
Credit pricing for AI and software products: how it works, how to price a credit, and the ledger and enforcement it needs to hold up in production.
The credit system works fine in staging. Then a customer runs three agent sessions in parallel, and the balance drains three times faster than it should because concurrent writes aren't handled correctly. The overage posts before anyone notices (on a Friday night, naturally).
Credit pricing is simple to sketch on a whiteboard. Keeping it correct under real workloads takes a ledger, a burn order, and a balance check that runs before every request.
Credit pricing is a model where customers purchase a balance of credits upfront and consume that balance as they use the product. It is also called credit-based pricing, or a credit-based pricing model.
Here, "credit" means a unit of value inside a software or AI product. (Loan pricing and college credits are a different search entirely.) If you're after the purchase flow, the prepaid credits guide covers it, and the full system design for LLM products lives in the AI credits guide.
Credits work like a currency the product understands. Each action, API call, token batch, or agent task reduces the customer's balance based on rules you define.
That's what separates it from pay-as-you-go, where usage is recorded first and billed later. With credit pricing, the purchase happens before usage, so the system has to track and enforce a live balance on every request.
Credit pricing runs as a loop: credits go in, actions draw them down, and the balance gets topped up, renewed, or expires.
| 📍 Stage | 🛠️ What happens | ⚙️ What the system has to do |
|---|---|---|
| Grant | Customer buys a pack, renews a plan, or receives promo credits | Record the grant with its amount, expiry, and category |
| Price | Each action has a credit cost | Map usage (tokens, calls, tasks) to credits |
| Deduct | The action runs and the balance drops | Check the balance and debit it at request time |
| Replenish | Balance runs low or the period renews | Top up, issue the next grant, or expire old credits |
Two systems share this loop. Billing handles the money: charging for credit packs, invoicing renewals, and processing top-ups. The entitlements layer reads the current balance and decides whether the next request can proceed.
Put more plainly, billing tells you what happened and the entitlements layer decides what’s allowed to happen.
They run on different clocks (billing thinks in invoices, entitlements think in milliseconds), but they have to agree. Otherwise usage, limits, and charges drift apart, and finance finds out first.
Credit pricing gives both sides something a flat subscription can't. Each benefit comes with a cost you'll pay somewhere else in the system.
Most of the challenges come down to one fact: a credit is an abstraction, and abstractions leak.
That last challenge is where credit pricing turns into an infrastructure project.
Credit pricing sits between a flat subscription and pure pay-as-you-go. Payment comes first, like a subscription, and consumption sets the cost, like pay-as-you-go.
| Model | When the customer pays | Customer's spend | Your revenue | What enforcement needs |
|---|---|---|---|---|
| Credit pricing | Before usage | Capped by the balance | Prepaid, recognized on use | Live balance check per request |
| Subscription | Each billing period | Fixed | Steady and recurring | Feature and seat access checks |
| Pay-as-you-go | After usage | Open-ended | Tracks usage, arrives late | Accurate metering and invoicing |
Credit pricing and pay-as-you-go both fall under the usage-based pricing umbrella, because consumption drives the bill. Pay-as-you-go pricing bills that consumption after the fact. Credit pricing collects payment first and enforces the balance as usage happens.
In practice, many AI products blend them: a subscription that includes a monthly credit grant, plus top-ups for heavy months.
Credit pricing models define how credits are issued, consumed, and replenished, and each model needs different enforcement behavior in the system.
| Model | How it works | Enforcement requirement |
|---|---|---|
| Prepaid block | Customer buys a fixed credit block upfront | Track block balance and deduct usage at request time |
| Auto-recharge | New block purchased when balance drops below a threshold | Detect threshold and trigger billing and new credit grant |
| Subscription with credit grant | Credits issued on a recurring cycle | Grant credits on renewal and apply expiry rules |
| Hybrid (subscription + top-up) | Base credits with additional purchasable blocks | Manage multiple blocks with burn order and priority |
| Promotional grant | Credits issued for trials or campaigns | Track category and prioritize depletion rules |
As usage gets less predictable, hybrid models tend to become the default. A base credit grant covers expected usage, while additional blocks absorb the spikes.
That flexibility costs you in enforcement. The system has to manage several credit sources at once and apply the right depletion rules without mixing balances or losing track of usage.
Credits, tokens, and wallets sit at different layers of the pricing model, from raw consumption up to how that consumption is packaged and controlled.
| Term | What it represents | Role in the system |
|---|---|---|
| Tokens | Atomic unit of AI consumption | Measured directly by the model during each request |
| Credits | Abstract pricing unit | Maps usage into a stable, customer-facing pricing model |
| Wallets | Container for balances | Holds and allocates credits across users or teams |
Tokens are the lowest level. They reflect what the model processes and work well for precise metering, but they expose internal details and make an awkward pricing unit. (Try explaining a context window on a pricing page.)
Credits sit above tokens as an abstraction layer. A credit can represent a fixed number of tokens or a higher-level action, so pricing stays stable even when the underlying model or cost structure changes.
Wallets group and manage balances. A wallet can hold one or more credit balances and be assigned at the organization, department, team, user, or individual-agent level.
In a hierarchy, every check evaluates the full chain from the caller up to the root, and only grants when every budget above allows. That's what makes allocation and governance possible, with a total budget split and tracked across many entities.
The abstraction you expose shapes the system design. Token-based pricing needs fine-grained metering at the model level. Credit-based models need a mapping layer between usage and price. Wallet-based systems need hierarchical balance tracking with allocation rules at every level.
To price a credit, work out what one action costs you, add your margin, and divide by what a single credit sells for. The formula:
Credits per action = cost per action ÷ (1 − target margin) ÷ price of one credit
Cost per action is everything the action consumes, so model tokens, GPU time, third-party API calls, and storage. Target margin and credit price are your packaging decisions. The formula just keeps the arithmetic honest once you've made them.
These numbers are illustrative. Plug in your own.
Now add a premium model that costs five times as much per token. It’s the same math, and that summary costs 40 credits. Your customers see two prices in one currency, and your margin holds on both.
Real products rarely have a single cost profile. One request might call two models, process a batch of files, and trigger an agent step, each with a different cost.
That's why credit costs usually end up as weighted formulas per feature, something like credits = (1.1 × model_a_tokens) + (5 × model_b_tokens), which Stigg supports through custom credit consumption formulas.
A fixed, round credit price is easier for customers to reason about, and the per-feature weights are where model cost changes get absorbed.
Credit pricing requires a data model that tracks more than a single balance, because enforcement, billing, and audit all depend on how credits are issued and consumed over time.
Each credit block issued to a customer carries its own attributes:
As customers buy credits over time, the system piles up blocks with different properties. Together they form a ledger of credit events, and the balance is something you derive from that ledger.
Each debit references the block it draws from, the order of consumption, and the timestamp of the event. That keeps usage aligned with expiry rules, cost basis, and accounting requirements.
The ledger also has to be append-only. Every credit grant and debit is recorded as an immutable event, and the current balance comes from those records. That structure keeps usage, billing, and finance data consistent and auditable.
Burn order defines which credit block the system debits when a customer has several active balances. It's a configuration decision that affects both user experience and financial outcomes.
When credits come from different sources, the system needs clear rules for how they're consumed:
Burn order needs to be configurable at the plan and customer level. A single global rule breaks down once promotional grants, trials, and standard purchases live in the same account.
The table below shows how different scenarios affect the ledger:
| Scenario | Burn order logic | Ledger requirement |
|---|---|---|
| Multiple paid blocks with different expiry | Earlier-expiring block first | Track expiry per block |
| Paid and promotional credits | Promotional credits first | Category field with priority rules |
| Soft depletion on empty balance | Usage continues and records overage | Negative balance or overage entries |
| Hard depletion on empty balance | Usage is blocked | Enforcement at request time |
Hard and soft credit depletion define how the system behaves when a customer's credit balance hits zero.
A well-designed check returns access-granted plus a soft-limit flag, so application code can distinguish ‘blocked’ from ‘in overage, allow and track it’ without inferring from the balance itself.
The right choice depends on the plan and the use case. A free tier might enforce strict limits, while an enterprise plan allows continued usage so a long-running job doesn't die halfway through.
Auto-recharge sits between the two. When the balance drops below a threshold, the system tops it back up to a target, under a spend cap that fails closed.
Once the configured monthly cap is reached, recharging stops rather than continuing to bill, so an automated retry loop can’t burn credits all weekend.
Rollover, expiry, and refund policies decide what happens to credits a customer paid for but hasn't used. Each choice shows up twice: once in the customer's trust, and once as an event in your ledger.
| Policy | What the customer experiences | What the ledger records |
|---|---|---|
| Expire at end of term | Use it or lose it each period | Expiry date per grant, expiry events |
| Roll over unused credits | Leftovers carry into the next period | A new grant or extended expiry for the remainder |
| Fixed window per grant | Each pack lasts a set time from purchase | Expiry stored per block |
| Forfeit on churn | Balance is lost if they cancel | Expiry or void events on cancellation |
| Void or refund a grant | Credits are removed after a refund | A void event with a reason, plus the refund in billing |
Expiry and burn order work as a pair. If credits expire, the soonest-to-expire block should burn first, or customers lose credits they'd have used anyway.
Credits that expire unused are called breakage. Finance recognizes that revenue under its own policy, which only works if every expiry is a recorded event with a cost basis attached.
Entitlements define what a customer is allowed to consume based on their plan and current credit state, and they're the enforcement layer that applies those limits during a request.
For credit pricing, an entitlement check runs in the request path and returns the data needed to decide whether the action can proceed:
Entitlements work differently from role-based access control, which answers whether a user has permission to access a feature. Entitlements check whether an AI agent or user has enough balance for the next request, and what should happen when that balance runs out mid-session.
Entitlement state comes from several sources that have to be resolved at runtime, before the request proceeds. The active plan sets the base, and inherited parent plans, add-ons, active trials, and promotional grants adjust it. When those sources conflict, the most generous value wins.
That resolution has to happen fast enough that it adds no perceptible latency to every API call. That's why it belongs in a dedicated entitlements layer that stays consistent across plans, customers, and requests as pricing changes.
In-house credit pricing systems usually break when several parts of the system try to update and enforce the same balance at the same time.
Most teams start in-house for good reasons. The first version is a table, a decrement, and a check, and it works fine at launch. The problems start when usage becomes shared, concurrent, and tied to changing plan state.
As the system scales, the pressure shows up in specific places:
By this stage, the system is coordinating state across requests, users, and plans, and the single balance column is the least of it.
At enterprise scale, that coordination has to hold across millions of checks per day without becoming a bottleneck. That's where most in-house implementations hit their limit, and the simple credits table turns into a system someone owns full-time.
Credit pricing at scale depends on keeping enforcement, the ledger, and billing in separate layers so each one holds up under load.
When those concerns share a layer, concurrent sessions produce race conditions, pricing changes need deploys, and the first enterprise audit request exposes holes in the transaction record.
Stigg is the usage runtime for AI products. Entitlements, credits, usage limits, and spend governance are enforced synchronously in the request path, before compute is consumed, and Stigg works alongside the billing system you already have.
With Stigg, engineering teams can:
Miro's team spent three months with three engineers on an in-house attempt before switching. With Stigg, they shipped AI credits in under six weeks. Miro estimates the switch saved 5,000 engineering hours, and its pricing changes now move six times faster.
If your credits table has started needing its own on-call rotation, the issue is probably architectural. Talk to a human about your stack, or start with the credits docs and see how the pieces fit.
The formula for calculating credit cost is credits per action = cost per action ÷ (1 − target margin) ÷ price of one credit. Cost per action covers model tokens, compute, and any third-party calls. For example, a $0.02 action at a 75% margin with $0.01 credits costs 8 credits.
Credit pricing is a prepaid form of usage-based pricing. Customers buy credits before they use the product, and the system deducts from that balance in real time. Classic usage-based billing records consumption first and invoices it at the end of the period.
You prevent double-spending with atomic debits on an append-only ledger and an idempotency key on every usage event. Each debit runs as a single transaction, so concurrent requests can't consume the same credits twice, and retried events only count once.
Yes, credit pricing works with subscription billing by issuing credits on a recurring cycle. The subscription defines the grant, and the credit system enforces usage against that balance.
You audit credit usage through an append-only ledger that records every grant, debit, expiry, and void. The balance is derived from those records, which lets finance reconcile usage, deferred revenue, and breakage against what customers paid.