LLM token billing means charging your customers for AI features based on the tokens (or another usage unit) their requests consume, so your revenue moves with your inference cost. Done well, a heavy user pays more than a light one and no customer can push your gross margin below zero.
Flat pricing works for software whose marginal cost is close to nothing. AI features are different: every request has a real, variable cost that a model provider bills you for. This guide covers why that matters, how to choose what to bill for, the common pricing patterns, and how to use limits and alerts so the bill you pay never outruns the bills you send.
Why AI products need usage-based pricing
Three properties of inference cost make flat pricing risky.
Cost per request varies a lot. A short question and a long document summary can differ by two orders of magnitude in tokens. Output tokens usually cost more than input tokens. On Anthropic’s pricing page (checked 2 November 2026), Claude Sonnet 5.5 is listed at $2 per million input tokens and $10 per million output tokens: output costs five times as much. Reasoning models add tokens the user never sees: Google’s Gemini API pricing (checked 2 November 2026) states that output prices include thinking tokens.
Usage is concentrated. In most products a small group of users generates a large share of requests. With a flat price, those users are subsidised by everyone else, and if they grow, your margin shrinks.
Your costs change without your consent. Providers change prices and tokenizers. The same Gemini pricing page lists Gemini 4 Argon at $2 input / $10 output per million tokens through 30 November 2026 and $4 / $20 from 1 December 2026. Anthropic’s page notes that the tokenizer of its newer models produces roughly 30% more tokens for the same text. If you resell tokens one to one, a model switch can change your customer’s bill; if you absorb the cost, it changes your margin.
Usage-based pricing doesn’t remove these risks, but it gives you a lever on each one.
Choosing the billable unit
The first decision is what your customer sees on the invoice. It doesn’t have to be the unit your provider bills you in.
| Unit | Good for | Watch out for |
|---|---|---|
| Input + output tokens (separately) | developer tools and APIs where buyers know tokens | customers must understand two prices; tokenizers differ by model |
| Total tokens | simple token pricing | output-heavy users cost you more than input-heavy ones at the same count |
| Requests or generations | end-user apps (one image, one answer, one summary) | cost per request must be bounded, or long requests eat the margin |
| Minutes or seconds | speech, transcription, video | maps cleanly to cost only if your provider bills by time too |
| Credits | mixed workloads across models and features | you have to publish a clear conversion, or customers feel tricked |
Rules of thumb:
- Bill in the unit your customer can predict. A developer calling your API can reason about tokens. Someone using a writing assistant thinks in documents, not tokens.
- Meter in the unit you pay for, even if you bill in another. Record input and output tokens per model internally, then convert to requests or credits for pricing. That way you can always compute real margin per customer.
- Bound the request. If you charge per request, cap the input size and maximum output so the worst case is still profitable.
A quick margin check
Suppose a typical request uses 2,000 input tokens and 500 output tokens on a model priced at $2 / $10 per million (the Sonnet 5.5 list price above). Inference cost is $0.004 + $0.005 = $0.009 per request. Charge $0.02 per request and you keep about 55% before other costs.
Now a power user sends 8,000 input and 2,000 output tokens per request. Cost is $0.016 + $0.020 = $0.036, and the same $0.02 price loses $0.016 on every call. Either price in tokens, cap the request size, or charge more for the large requests.
Pricing patterns for AI usage
Most AI products end up with one of four patterns.
- Pure usage. Pay per token or request, nothing else. Easiest to explain to developers; revenue is unpredictable and small accounts cost you support time without paying for it.
- Base fee + included usage + overage. For example $29 a month including 2 million tokens, then a price per additional million. The base fee covers fixed costs and the included amount sets expectations. This is the most common pattern for AI SaaS.
- Prepaid credits. The customer buys a pack of credits and each action spends some. You are paid before you spend on inference, and a zero balance is a natural hard stop. It works well for consumer and prosumer apps.
- Tiers. Unit prices that fall as volume grows (graduated tiers), so large customers get a better rate without a custom contract. Keep the lowest tier price above your highest expected cost per unit.
You can mix them: a base fee with included tokens, graduated overage, and top-up credit packs for customers who want a hard ceiling.
Limits, entitlements and alerts
Pricing protects margin over a month. Limits protect it within an hour.
- Hard limits stop service when a customer reaches their allowance: free tiers, trials, prepaid balances.
- Soft limits let usage continue but trigger something: an email at 80%, overage pricing after 100%, a sales call at 300%.
- Rate limits per window (per hour or per day) catch runaway loops, such as an agent stuck retrying, before they become a month’s worth of tokens.
The key design question is where the check happens. Billing totals are usually computed asynchronously, but your app needs an answer before it calls the model. That means a fast counter you can read on the request path, which is allowed to be a second or two behind, and a reconciliation that corrects it against the authoritative totals.
Alerts need one more property: they must fire once per threshold. A customer who gets fifteen “you’ve used 80%” emails because three servers saw the crossing at the same time will stop reading them.
Margin protection checklist
- Meter input and output tokens per model, even if you price in requests or credits.
- Price the lowest tier above your worst realistic cost per unit, not your average.
- Treat provider discounts (prompt caching, batch processing) as your margin, not your customer’s discount, unless you choose otherwise. Anthropic lists a 50% Batch API discount on the same pricing page.
- Version your prices. When a provider raises prices, publish a new version for new periods instead of editing the old one.
- Make ingestion idempotent. Retried requests are common with LLM calls (timeouts, streaming disconnects); a duplicate event is free tokens for the customer, a dropped one is free tokens for everyone.
- Set per-window limits on expensive features, and alert before the limit, not after.
How Payrudder meters LLM usage
Payrudder is a usage metering and billing platform written in Go; NAFRU built it as the shared billing layer of its own AI and SaaS apps. For token billing, the pieces are:
Meters. A meter such as ai_tokens with SUM aggregation over a tokens property adds up every event’s quantity per customer and period. You can define separate meters for input and output tokens, and a meter can carry an equality filter on an event property, for example model, so each model gets its own meter. Quantities are exact decimals and money is never a float, so tiny per-token prices don’t drift.
Idempotent ingest. Each event carries an idempotency key, required for live keys. A retry comes back as duplicate and is never counted twice; the same key with a different payload is rejected. Using the provider’s response id as the key is a simple choice. An event looks roughly like this:
{ "idempotency_key": "resp_8f2c", "customer_external_id": "cus_42",
"meter_code": "ai_tokens", "quantity": "1500",
"event_time": "2026-11-03T10:15:00Z", "properties": { "model": "model-x" } }
Pricing. Per-unit, graduated tiers, packages and a base fee on the plan cover patterns 1, 2 and 4 above. Plan versions are immutable, and re-rating a closed period under a new version bills only the difference as a correction invoice. For pattern 3, credit packs are sold through payment links or the customer portal; your backend spends credits with an API call that refuses, taking nothing, when the balance is too low, and a credits.low webhook fires once when a balance crosses your threshold.
Limits. limits-svc keeps per-customer counters in Redis, updated atomically with Lua, per billing period and optionally per hour, day, week, year or lifetime. Your app asks for the entitlement before serving a request and gets used, limit, allowed and an as_of time. Thresholds such as 80% and 100% fire once each (a Redis SET NX plus a deterministic event id), and an email alert is sent. A reconciliation loop corrects the counters against the authoritative totals. Two honest caveats: Payrudder does not block ingest when a limit is passed (usage that happened is recorded; your app decides whether to serve the next request), and in our benchmark on an M4 laptop the p99 target for entitlement reads at 2,000 requests per second was missed.
The AI token billing use case shows a full setup, and the usage metering page covers meters and aggregations. One more status note: the Paddle and iyzico payment adapters are written from the providers’ docs and tested against fixtures, but have not yet been run against their sandboxes.
Summary
AI features have a cost on every request, so your pricing needs a usage component that tracks it. Meter in the unit you pay for, bill in the unit your customer understands, and bound the worst case with limits and alerts that fire once. Payrudder Cloud is in early access, charged by system usage rather than a share of revenue. The plans are on the pricing page.