Agent-first Billing
A Field Guide
How we’re building the most ambitious metering and billing engine for AI software.
[ Request early access ]00Core principles
Three ideas run through everything that follows. Every number comes from events, agents are customers like any other, and billing answers next to your code without waiting on Polar.
Everything is an event
Every number Polar shows is computed from the events you send.
Native to agentic workflows
Agents do the legwork, and people make the call.
Zero latency & fault tolerance
Checks are answered next to your code, without waiting on the network.
01Billing as code
The catalogue is a file. Products, prices, meters and entitlements are declared once, reviewed as a diff, and applied to an environment, so a pricing change goes through the same review as any other code.
The config
A product is a file you review and apply.
Review and apply
The CLI reads the file, shows the plan, asks, and applies it.
Margin checks
An unprofitable price fails the build.
02Events
An event is a fact: at this time, this customer, through this actor, did this thing, this much. The event log only grows, and every usage number is derived from it.
What’s in an event
Who did what, when, and how much.
The event log
Append only. Events are added, never changed or removed.
Late events
An event counts at the time it happened.
AI gateways
Model calls through an AI gateway are metered with no extra code.
03Meters
A meter turns events into a number: which events count, and how to add them up. Polar keeps that number current as events arrive, and can always rebuild it from the events behind it.
How does a meter work?
A meter turns events into one number.
Reducers and buckets
Events add up into five-minute buckets, and an invoice adds up the buckets.
Rates and tiers
One month of usage, priced two ways.
04Local-first
Outpost runs inside your own process. It folds every event with the reducers Polar runs, in your own Redis, so a check is answered where your code is. Polar settles the usage behind it and sends that back.
Where Outpost sits
Between your app and Polar, with its state in your Redis.
Local-first checks
Answered from the state in your own Redis. Polar catches up behind it.
Reconciliation
Outpost answers now. Polar’s snapshots correct it as buckets close.
05Identities
You might sell to agents, spawn them on a customer’s behalf, or both. Polar calls every customer an identity, human or machine, and gives every one the same meters, credits and entitlements.
Nested identities
People and agents, in whatever hierarchy you design.
Usage by identity
Usage adds up the tree to whoever pays.
Unit economics
Revenue, cost and margin for every identity in the tree.
Shared and delegated
Credits and limits flow down the tree the way you set them.
06Guardrails
A guardrail is a condition on a number Polar already keeps: a meter, a credit balance, a margin. When the number crosses it, a signal fires and runs your side effect, so you can move a customer to a cheaper model before the credits run out.
Signals
A side effect that runs when a number enters or leaves a threshold.
Margin floor
When a customer’s margin drops below a minimum, slow them down.
07Simulations
Try a pricing change before your customers do. Branch your billing, replay last month’s real usage through it, pull levers like churn and growth, and see revenue, margin and who would pay more. When it looks right, deploy it like any other change.
Branch and replay
Try a new price on last month before your customers see it.
Levers and outcomes
Pull a lever and see what last month would have looked like.
08Credits
Credits are a balance derived from two kinds of event: grants, which add, and usage, which takes away at the meter’s rate. When they run out, Polar keeps counting, and your app decides what happens at zero.
The credit balance
A grant fills it and every metered event drains it.
Grants and expiry
A grant is an event with a start and, sometimes, an end.
Running out
Polar keeps counting. What happens next is up to you.
09Entitlements
Entitlements are what a subscription unlocks. When the subscription changes state, every entitlement on it switches with it.
How entitlements work
The subscription’s state moves every gate.
On a product
What a product grants, held by the customer while they subscribe.
10Bring your own PSP
Polar works out what to charge. Who takes the payment is up to you: the processor you already use, like Stripe or Adyen, or Polar as your merchant of record.
Bring your own PSP
Polar runs the billing. Payments go through the processor you choose.
Polar Billing
Billing, payments and tax in one, with Polar as your merchant of record.
Early access
We're building agent-first billing with a small group of AI startups. Tell us about yours, and we'll bring you in early, with a direct line to the team building it.