Meters
A meter turns the events you send into the quantities you bill. You send Paid what happened, such as a model call with its token counts, and a meter decides what part of it is billable: every call, the output tokens, or the number of distinct conversations. Meters live in Paid rather than in your code, so you can change what you charge for without changing what you send.
Use a meter to:
- Bill for usage by pointing a usage price or a rate card at it.
- Report usage to your team and your customers with usage summaries, whether or not you charge for it.
- Bill for results rather than activity, with a workflow meter.
Meters are in the meters=v1 private beta: send Paid-Beta: meters=v1 with each request.
How a meter works
A meter does two things to every event you send:
- It selects. It reads only the events whose name it lists, and only those that pass its filters.
- It measures. It aggregates what it selected over each billing period: it counts the events, or sums, averages or takes the maximum of a field on them.
The result is a quantity in an explicit unit, such as 412000 token, for each customer and billing period. Prices turn that quantity into money or credits.
This page covers event meters, which measure over a billing period. A workflow meter instead groups related events, such as the messages in one support ticket, and measures each group by its outcome.
Create a meter
Lucerne runs a chat app that calls a language model for every message. It sends one chat_message event per reply, with the model call as an inference cost line, and charges for the output tokens. This meter sums them:
API
Dashboard
Create a meter with a key, the events it reads and how it measures them.
Prices and the API refer to the meter by its key or its mtr_ ID. The key is unique on your account and can’t change.
Select events
A meter reads events by name, given in one of two ways:
eventNames: exact names, such as["chat_message"].eventNamePattern: a regular expression for a family of names, such as^report_.
Event names aren’t registered anywhere, so a name you never send isn’t an error. It shows up as a warning in the meter’s health.
Add filters to narrow the selection. Every filter must hold, and an event without the filtered field doesn’t match:
Measure
measure.events.aggregation sets how the selected events add up over a billing period:
Every aggregation except count reads one field, named by its path. unit names what the quantity is in, such as token or conversation; for count it defaults to event. A meter’s unit is what’s counted. It’s separate from the currency or credit currency a price charges in.
To bill per conversation instead of per message, count distinct correlation IDs:
Paths
Reading tokens from cost lets you send them once, then both bill them and see what they cost you. To bill input tokens, sum cost.inference.uncachedInputTokens, which Paid calculates. inputTokens also includes cached tokens, which a cache meter may already count.
A value at a path must be an integer or a decimal string, such as "12.5". A JSON number with a fractional part is rejected, because binary floating point can’t represent most decimal amounts exactly.
How it bills
Lucerne prices the meter at $10.00 per million output tokens: a usage price with unitAmount: "1000" (cents) per: "1000000". In November, Northwind’s users get replies totalling 18,450,000 output tokens:
Paid calculates the charge exactly and rounds once, to whole cents, on the invoice line.
Split usage by dimension
groupBy splits a meter’s quantity by up to three paths, such as cost.inference.model. Each group gets its own quantity, so a rate card can price each model differently and usage summaries can report on them. A meter with groupBy is priced through a rate card, not a single price.
Check a meter’s health
A meter’s definition lives on the server, so a typo in an event name or a path doesn’t fail when you send events. It shows up in the meter’s health instead:
Retrieve the meter after your first events arrive, and check matchedEvents24h isn’t 0.
validationMode decides what happens to an event with an invalid value at a path the meter reads. With lenient, the default, the event is stored but not billed by this meter, and counted in invalidValues24h. With strict, the event fails ingestion with a per-item error.
Change or retire a meter
Everything that decides what a meter bills is fixed when you create it, so every past invoice matches its meter. Update a meter to change only its name, description, validationMode and metadata.
To change what’s billed, create a new meter, create prices on it, and amend the orders that should use them.
Archive a meter to stop it measuring. It stays readable, because invoices refer to it. Archiving fails while an active, activating or paused order uses the meter through a price or rate card.
Single-event meters
A third mode, measure.type: "singleEvent", measures each event on its own, such as the characters in each email or the pages in each document. Use it with tierScope: "event" on a price, so tiers apply to each event rather than to the period’s total.
Single-event meters are drafted and may change before they’re released.