Blog
/
Guides

Usage Metering: How It Works, What to Meter, and Examples

Usage metering explained for engineers: how events become metrics, what to meter, real-time vs. batch pipelines, and where metering breaks at scale.

Sara NelissenSara Nelissen
Written by
Sara Nelissen
Last updated
July 6, 2026
read time
7
minutes
Usage Metering: How It Works, What to Meter, and Examples

Table of contents

Usage metering works fine until an AI agent fans out across a multi-step workflow and the pipeline falls behind. Enforcement reads stale state, a customer sails past their limit, and by the time the meter catches up an hour later, the overage has already been charged.

Most of that damage happens in the plumbing: how events get ingested and deduplicated, how they're aggregated, and how quickly the current number reaches the code deciding whether the next request runs.

What follows is the full usage metering pipeline, from the event your app emits to the balance your enforcement check reads, along with how to choose what to meter, what customers need to see, and where in-house builds tend to run out of road.

What is usage metering?

Usage metering is the process of capturing product usage as events, aggregating those events into measurable quantities, and making the totals available for enforcement, billing, and reporting.

For engineering teams, usage metering is the pipeline that records what was consumed, by whom, and when. API calls, tokens, GPU seconds, storage, and agent actions all qualify, as long as each unit can be traced back to a customer.

Without it, there's no reliable way to enforce limits, calculate charges, or show customers what they've used.

One quick disambiguation, since the term gets shared: software usage metering is unrelated to the smart meters utilities install for electricity, gas, or water. Both measure consumption, but the data and the stack have almost nothing in common.

How usage metering works

Usage metering works by capturing raw usage events, rolling them up into aggregated metrics, and handing those metrics to the systems that price, enforce, or display them.

The pipeline has three stages, and each one adds structure before the data reaches billing or enforcement:

Stage What it does Engineering requirement
1. Ingestion Captures raw events from your app and infrastructure High-throughput intake, validation, deduplication
2. Metering Aggregates events into per-customer metrics Aggregation logic, real-time or batch processing
3. Rating Applies pricing rules to metered totals Pricing engine, credit handling, overage detection

1. Ingestion

Ingestion collects raw telemetry such as API calls, tokens consumed, storage written, and agent actions completed. Each event needs a handful of fields to be useful downstream:

  • Customer ID: who the usage belongs to
  • Event name: what happened, such as llm.completion or report.export
  • Dimensions: the properties you'll want to slice by later, like model, region, or feature
  • Timestamp: when the usage happened, which can differ from when the event arrived
  • Idempotency key: a unique ID that lets the pipeline count a retried event exactly once

Dimensions are cheap to add on day one and painful to backfill on day 300, so capture more than you think you'll need.

The two failure points at this stage are retries and late arrivals. Clients retry after timeouts, so without an idempotency key the same event gets counted twice. Events that arrive out of order need a clear rule for which aggregation window they belong to.

2. Metering

Metering converts the cleaned event stream into aggregated metrics per customer, per feature, and per period.

A storage service, for example, samples usage over time and rolls it up into billable units like GB per month.

The aggregation method depends on what you're measuring:

  • Count: number of events, such as API calls or actions
  • Count unique: distinct values, such as monthly active users
  • Sum: total volume, such as tokens or data transferred
  • Max: highest observed value, such as peak concurrent sessions
  • Average: mean value over a period, such as average request size

Choosing the wrong aggregation method leads to incorrect bills and makes reconciliation painful, because every disputed invoice turns into a debate about what the number was supposed to mean.

3. Rating

Rating applies pricing rules to the metered totals to calculate charges, including tiers, included allowances, credits, discounts, and overage fees.

This is where metering hands off to billing, which brings its own edge cases like proration and invoice timing. Stigg's guides to metered billing and event-based billing cover that side in depth.

Real-time vs. batch usage metering

Real-time and batch usage metering differ in when they process events, and that timing decides whether the system can enforce anything.

Batch metering processes events at set intervals, such as hourly, daily, or at the end of a billing period. It works for billing reconciliation, where accuracy matters more than speed, but it can't stop usage before a limit is exceeded.

Real-time metering processes events as they arrive and updates usage state immediately. That lets the system check balances, validate entitlements (what each customer's plan, add-ons, and credits allow them to use), and allow or block an action before it runs.

Approach How it works What it enables Limitation
Batch Processes usage at fixed intervals Accurate billing and reconciliation Can't enforce limits before usage occurs
Real-time Processes events as they happen Pre-request checks and enforcement Higher infrastructure cost and complexity

For AI products, where a single agent session can generate thousands of events in minutes, batch metering creates an enforcement blind spot. By the time the pipeline processes those events, the usage has run and the overage has posted.

In practice, production systems usually run both: a hot path that aggregates in short windows for enforcement, and a cold path that stores every raw event for audits, disputes, and rebuilding totals when a bug slips through.

How to choose what to meter

Choose a usage metric that customers already understand, can estimate in advance, and that moves with your cost of serving them. When one unit can't do all three, use more than one meter.

This is a metering design decision as much as a pricing one, because the unit you pick decides which events you emit, which dimensions they carry, and what your enforcement layer checks on every request.

1. Pick a unit customers can forecast

API calls, messages, documents processed, and minutes of audio all pass this test. If you have to explain the unit before anyone can buy it, your support team will be explaining it forever.

2. Make usage simple to forecast

A customer planning next quarter's budget should be able to guess their usage within a reasonable range. Tokens are precise but hard for most buyers to forecast, which is one reason many AI products sell credits that convert to tokens behind the scenes.

3. Tie the unit to what it costs you

If one request can cost far more than another (long context windows, reasoning modes, and bigger models all do this), a flat per-request meter hides margin risk. Meter the cost driver directly, or capture it as a dimension so you can weight it later.

4. Use more than one meter when one unit hides the cost

An AI product might meter seats for access, credits for model usage, and storage on its own line. For API products, the API metering decisions (what to measure, where to capture it, and how to enforce it) follow the same logic at the endpoint level.

Usage metering examples

Usage metering shows up anywhere consumption varies from one customer to the next. Here's what typically gets metered across product types:

Product type What gets metered Typical aggregation
SaaS Active users, documents, workflow runs Count unique, count
API products Requests by endpoint or tier Count
Cloud infrastructure Compute hours, storage, data egress Sum, average over time
LLM APIs Input and output tokens by model Sum
AI agents Tasks, tool calls, credits burned Sum, count
Communications Messages sent, call minutes Count, sum

Model providers are the clearest case. OpenAI's API pricing lists separate rates for input, cached input, and output tokens on each model, with higher rates for long context, so every request has to be metered by model, token type, and context length before it can be priced.

Agents push this further, because one user-facing task fans out into many model calls and tool executions that all need to roll up to the same customer and task. For more patterns, see these usage-based pricing examples.

Benefits of usage metering

Usage metering lets price track the value customers get, so revenue grows as they use more and your costs and revenue move together.

  • Price matches value: customers pay for what they consume, which lowers the barrier for small accounts to start and lets heavy users scale without renegotiating.
  • Revenue grows with usage: expansion happens as customers use more of the product, which ties growth to adoption.
  • Costs and revenue stay in sync: in AI products, every request carries inference cost, so metering is how you see margin per customer, per feature, and per model.
  • Room for hybrid plans: once usage is metered, you can combine a subscription with included usage, credits, or overage (a hybrid model) without rebuilding the pipeline.

Every one of these benefits depends on a meter that finance, engineering, and customers all trust, so it pays to get the event data clean before layering usage-based billing on top.

Why usage metering is harder in AI products

Usage metering is harder in AI products because consumption is more granular, every unit carries real infrastructure cost, and a single user action can span many steps.

AI workloads add three challenges that most SaaS metering never had to handle:

  • Granular, variable units: token usage changes with input length, output length, model choice, and reasoning mode, so two similar-looking requests can differ widely in cost.
  • Direct cost impact: each unit maps to compute you pay for, so metering errors hit margin as well as billing accuracy.
  • Multi-step workflows: one user action can trigger several model calls, tool executions, and retrieval steps, and each step consumes usage that has to be attributed correctly.

The system needs to track consumption at each step so the total reflects what happened behind a single user action. A single request-level event misses that detail when usage is spread across internal operations.

Usage metering vs. enforcement: What's the difference?

Usage metering records what was consumed, while enforcement uses that data to decide what can happen next, in real time. The two layers play different roles:

Layer What it does When it runs Purpose
Metering Captures and aggregates usage events After usage occurs Billing, reporting, analytics
Enforcement Applies limits and decides allow or block During the request Controls usage and prevents overage

Usage-based billing tools focus on metering. They capture events, count usage, and pass totals to billing systems for invoicing, with enforcement handled somewhere else at request time.

Enforcement lives in the entitlements layer. It knows what a customer is allowed to consume based on their plan, add-ons, credits, and current usage, and what should happen when they reach a limit.

Why the enforcement check has to run locally

This is the failure mode from the top of this article. The looping agent above only overspends because the check reads a number the pipeline hasn’t updated yet.

The check also has to be fast, so it can't make a remote call on every request without adding latency that compounds under load. Systems that keep latency predictable at production scale tend to:

  • Keep entitlement and balance state in a local cache
  • Resolve checks on cache hits without a network call
  • Fetch from an upstream service on cache misses, with a timeout
  • Return configured defaults when the upstream service is unreachable

For teams with data residency requirements, the enforcement layer has to run inside their own infrastructure. A bring-your-own-cloud (BYOC) deployment keeps usage and entitlement data within the VPC and removes any dependency on external uptime for read-path decisions.

What challenges come with usage metering?

The biggest usage metering challenges show up on two sides: the business has to define units and live with variable revenue, and engineering has to keep usage state correct under load.

For the business and your customers

  • Unit definitions: everyone has to agree on what counts as one unit, including the awkward cases like failed requests, cached responses, and retries.
  • Bill shock: customers who can't see usage build up find out at invoice time. A customer's integration enters a retry loop on a Friday night and bills millions of calls by Monday.
  • Revenue swings: revenue moves with usage, so forecasting gets harder and a quiet month at one large account shows up in your numbers.
  • Customer budgeting: finance teams on the buyer side want a number they can plan around, which is why prepaid credits, caps, and spend alerts matter as much as the meter itself.

Where in-house usage metering breaks in production

Most teams build a basic metering setup early on, and that's a reasonable call. A credits table and a decrement function work at low scale, and the decision to build in-house makes sense at that stage.

The issues show up as usage grows and the system has to stay consistent under load:

  • Concurrent usage: multiple users drawing from a shared balance create race conditions. Atomic debits against an append-only ledger keep usage accurate.
  • State consistency: cached entitlement data goes stale when plans change mid-session, so the system needs a clear cache refresh and fallback strategy.
  • Attribution: AI workflows span multiple model calls and tool steps, and each step has to map back to the right customer, feature, and session.
  • Auditability: finance needs an append-only record of usage and credits. Mutable balances make reconciliation and dispute handling painful.
  • Plan changes: mid-cycle upgrades introduce edge cases around prorated credits, active limits, and legacy plans.

At this point the problem shifts from tracking usage to keeping state consistent across the whole system.

Enterprise customers make it harder still. They need usage tracked and enforced independently across departments, teams, users, and agents in one organization, a cardinality most in-house systems weren't designed for.

It usually gets retrofitted under deadline when the first enterprise contract demands it.

What customers should see

Customers should be able to see their current usage in real time, get warned before they hit a limit, and pull usage data into their own systems.

  • A live usage view: current consumption against plan limits or credit balance, broken down by feature, user, or agent where it matters.
  • Alerts before a limit: notifications as usage approaches a threshold, plus a predictable behavior at the limit (block, allow overage, or top up).
  • Usage exports and APIs: finance and platform teams want usage data in their own warehouse and dashboards, on their own schedule.

Datadog's Usage Metering API is a good reference for exports: customers pull hourly, daily, and monthly usage, delayed by up to 72 hours. That's plenty for cost reporting and too slow to warn anyone before they hit a limit, which is why exports work best alongside a live view.

All three should read from the same metered data your enforcement layer uses. If the dashboard says 80% and the enforcement check says 100%, customers will notice before you do. For AI products, this visibility is part of AI usage control, alongside the limits themselves.

Turn usage metering into decisions your app can act on

Accurate usage metering is the foundation, but a meter that only reports after the fact leaves the expensive question unanswered: should this request run?

Metering tells you what happened. Stigg decides what's allowed.

Stigg is the usage runtime for AI products. It works alongside your billing provider and runs real-time metering, credits, entitlements, and governance in one enforcement layer that sits in the request path.

With Stigg, engineering teams can:

  • Report usage as raw events or pre-calculated values, with idempotency keys so retried events count once
  • Run metering inside your own VPC with BYOC metering, at 1M+ events per second on Kafka, Flink, and ClickHouse, with no per-event cost
  • Check entitlements and credit balances in the request path at p99 under 10ms, served from an in-memory cache through the Sidecar or the Node.js SDK
  • Keep enforcing during outages, with cached state and configured defaults when the upstream API is unreachable
  • Burn credits from a double-entry ledger with per-grant expiry, cost basis, category, and burn priority
  • Set budgets at the org, department, team, user, or individual agent level, and attribute every deduction to a customer, feature, and model
  • Sync usage to billing providers like Stripe or Zuora while enforcement stays independent of the billing layer

You don't need to adopt the whole stack, since each component works on its own and teams often start with credits or enforcement and expand from there.

When metering and enforcement read from the same real-time state, pricing changes become configuration work, and the audit trail is already there when finance asks for it.

If your usage pipeline is starting to creak under agent traffic, talk to a human about your stack, or start with the AI quickstart in the docs.

FAQs

What is the difference between usage metering and billing?

The difference between usage metering and billing is that metering records what was consumed, while billing applies pricing rules to that data to generate invoices. Metering runs continuously, and billing runs on the metered totals after the fact.

What is software metering?

Software metering is the practice of tracking how software is used, by whom, and how much. It originally meant monitoring application use for license compliance. In SaaS, API, and AI products, it usually means usage metering for enforcement, billing, and reporting.

What is an example of usage metering?

A common example of usage metering is an LLM API counting input and output tokens per model for each customer. Each request emits an event with the customer ID, model, and token counts, the pipeline sums them per billing period, and the totals drive both limits and invoices.

What is the difference between real-time and batch usage metering?

The difference between real-time and batch usage metering is when events are processed. Batch metering processes usage at fixed intervals and works for billing reconciliation, while real-time metering processes events as they arrive so the system can block requests before a limit is exceeded.

Why does usage metering break under concurrent load?

Usage metering breaks under concurrent load when multiple sessions draw from a shared balance at the same time and the system lacks atomic operations. Two requests can read the same balance before either commits, both go through, and the balance goes negative without triggering a hard limit.

Latest news.

One email per month.
From engineers, for engineers.

Thank you! Your submission has been received.
Oops! Something went wrong while submitting the form.