AI metering measures how much AI your application consumes and who consumed it. It captures units such as input tokens, output tokens, tool calls, and audio seconds, then aggregates them by customer, feature, or workflow. Those measurements support AI cost tracking, usage allowances, and usage-based billing.
What is AI metering?
AI metering is the collection and aggregation of usage events from AI workloads. Each event answers four questions: what resource was used, how much was consumed, when it happened, and which customer or workload it belongs to.
For a simple chatbot, LLM metering might record input and output tokens for each response. For an AI agent, the same customer request can include several model calls, paid searches, and MCP tool invocations. A useful meter preserves those individual events while linking them to one execution.
Teams searching for AI usage metering, LLM token metering, or AI consumption tracking often share the same practical problem: a provider total does not explain which customers and features generated the usage.
Core components of AI metering
A complete AI metering setup has four parts. Most teams start with the first two and add the others as AI cost becomes a material share of revenue.
- Usage capture. Record input tokens, cached tokens, output tokens, model, tool calls and other billable units for every AI call, with the customer, feature and workflow that caused it.
- Cost attribution. Price each call at the model’s rate, including cached, batch and long-context rates, and add the calls up by customer, plan, feature and workflow. This turns a provider invoice into AI cost per customer.
- Budgets and limits. Set spending thresholds by customer, workflow or model and alert an owner when they are crossed. Hard limits that refuse requests must run in the request path, in your application or an AI gateway.
- Revenue and margin. Compare AI cost with what each customer pays from Stripe or your billing system to get margin after AI cost, or send the measured usage to billing to charge for it.
Ganivra covers usage capture, cost attribution across 165 priced models, budget alerts, and margin after AI cost per customer. It works alongside your billing system rather than invoicing customers itself.
What should you meter in an AI application?
Choose units that match actual consumption. Keep incompatible units separate; adding tokens to audio seconds does not produce a meaningful usage total.
| Resource | Usage to capture | Why it matters |
|---|---|---|
| LLM inference | Input, output, and cache-related token categories; provider and model | Different categories can have different rates |
| Agent and MCP tools | Tool identity, invocation count, direct fee, execution ID | Token counts miss paid tools and multi-step work |
| Voice AI | Audio units and connected telephony duration | Speech and carrier consumption may be billed separately |
| Images and other media | Count, size, quality, duration, or provider-specific unit | A request count alone may not explain cost |
| Product outcomes | Reports generated, tickets resolved, or completed workflows | Connects resource consumption to the unit customers value |
Record failures and retries too. An unsuccessful customer request can still incur provider charges. For agent-specific attribution, see our MCP cost tracking guide; for audio workloads, see voice AI unit economics.
AI metering vs. cost tracking vs. usage-based billing
Choosing a customer-facing unit? Read AI Usage-Based Billing: Tokens, Credits, or Outcomes? for a comparison of pricing models and worked billing examples.
These functions share data but answer different questions. Metering asks how much was consumed. Cost tracking applies your supplier rates. Customer billing applies your selling prices and contract terms.
- Metering: this tenant consumed 2 million input tokens and 400,000 output tokens.
- Cost tracking: those units cost your business a calculated amount under the applicable provider rates.
- Billing: the tenant owes a charge under its subscription, credits, or usage pricing agreement.
You can meter tokens internally while charging customers per report. You can also meter every request while offering a flat monthly subscription. The important link is between the customer-facing unit and its actual cost-to-serve.
A token meter alone does not provide an invoicing system. For an example of usage aggregation, OpenMeter’s metering documentation describes summing token quantities from usage events. Billing adds the commercial rules on top of those measurements.
How to implement AI metering
1. Define customer and execution boundaries
Choose a stable internal tenant ID and generate an execution ID for each user task. Pass both through asynchronous jobs, model calls, and tools. Keep production and test usage separate. Prefer internal IDs over customer emails or prompt contents.
2. Capture actual consumption at each call
Use provider-reported usage when available. An estimate from the user’s prompt can miss system instructions, retrieved context, output, and reasoning work. For streaming requests, collect the final usage information when provided; if a connection ends before usage arrives, mark it incomplete and reconcile it later.
3. Normalize without losing provider details
Preserve provider, model, timestamp, raw unit categories, status, and application context. Providers may report cached or reasoning tokens differently. Make categories mutually exclusive before pricing them so cached tokens are not charged twice. Store the original usage details for investigation.
4. Make event delivery retry-safe
Assign a stable event ID before delivery and deduplicate repeated submissions. A retry of telemetry delivery should keep the same event ID; a new model attempt should receive a new event ID because it may consume additional resources. Buffer events durably when losing usage would affect invoices.
5. Apply versioned rates
Keep measured quantities separate from prices. Resolve rates using the provider, model, usage category, contract, and effective date. Preserve an explicit unpriced state when a rate is missing. Unknown cost is not zero cost.
6. Aggregate and reconcile
Sum each usage unit by tenant and billing window, with a documented timezone and policy for late events. Compare calculated supplier costs with provider usage exports or invoices. Investigate differences from missing events, credits, rounding, or rate changes before relying on totals for customer billing.
7. Connect measurements to decisions
Use customer and feature totals to identify expensive workflows, review allowances, or investigate retries. If you need hard quotas, design a separate enforcement path that accounts for concurrent requests and in-flight usage; a delayed analytics total cannot guarantee a spending cap.
AI token metering: a worked cost example
Assume one customer generates 1,000 reports in a month. Across all attempts, including retries, the meter records the following consumption. These are illustrative rates, not a provider price quote. Token categories here do not overlap.
| Metered usage | Example supplier rate | Cost |
|---|---|---|
| 2,000,000 uncached input tokens | $2 per million | $4.00 |
| 500,000 cache-read tokens | $0.50 per million | $0.25 |
| 400,000 output tokens | $8 per million | $3.20 |
| 1,000 paid tool calls | $0.005 per call | $5.00 |
| Total measured AI cost | $12.45 |
$12.45 ÷ 1,000 = $0.01245
If each completed report earns $0.05, revenue is $50 and the amount remaining after these measured AI costs is $37.55, or 75.1% of revenue. That is not fully loaded gross margin: hosting, support, payment fees, and other relevant delivery costs still need to be included. See how to calculate AI SaaS gross margin for the complete formula and a worked example.
This example shows why counting only tokens can mislead pricing decisions. The tool calls contribute $5 of the $12.45 measured cost. It also shows why cost per successful outcome should include the consumption of unsuccessful attempts in the same cohort.
How to choose AI metering software
Evaluating specific tools? Our OpenMeter vs. Ganivra comparison explains the fit for usage billing and AI cost attribution.
Start with your decision: internal cost visibility, customer billing, or real-time usage enforcement. Evaluate the capabilities required for that decision with a representative workflow.
- Coverage: can it capture your models, tools, and non-token usage?
- Attribution: can you inspect usage by customer, feature, and execution?
- Correctness: how does it handle duplicate delivery, delayed events, missing usage, and corrections?
- Pricing: can it distinguish contract rates, catalog rates, and customer selling prices?
- Reconciliation: can you trace an aggregate back to its underlying events?
- Integration: how will measured usage reach your billing or entitlement system?
A useful evaluation includes a successful call, a charged failure, a retry, a cached request, and a paid tool call. Verify the totals and customer attribution before expanding instrumentation.
Start tracking AI usage and customer costs with Ganivra
Ganivra connects model and MCP consumption to customers, features, workflows, and executions. Its telemetry API accepts token usage and additional usage details, and resolves costs from provider-reported amounts, workspace contract rates, or its versioned catalog.
Start with one workflow: attach customer and execution identifiers, send model and tool events, and inspect the resulting cost breakdown. The Ganivra integration guide covers the event contract and SDK setup. Use the resulting attribution to understand the cost behind your pricing; customer invoicing and real-time enforcement require their own billing and application logic.
Frequently asked questions about AI metering
What is AI metering?
AI metering measures how much AI your application uses and who used it. It counts things like tokens, model calls, tool calls and audio seconds, and tags each one with the customer, feature or workflow behind it. That lets you see AI cost by customer and price your product on real usage.
What are the core components of AI metering?
There are four: usage capture, cost attribution, budgets and limits, and revenue and margin. Usage capture records tokens and calls. Cost attribution turns them into dollars per customer. Budgets alert you or stop runaway spend. Revenue and margin compare AI cost with what each customer pays.
How is AI metering different from AI billing?
Metering measures usage; billing charges for it. In between, rating puts a price on the usage. Billing then applies the customer's contract, allowances and credits to create an invoice. What you pay your AI provider and what you charge your customer are separate prices.
Is counting tokens enough for AI usage metering?
Only if tokens are your only cost. AI agents also use paid tools, search, audio and infrastructure. Track each of those separately and link them to the same request.
How do you track AI usage by customer?
Add your customer ID to every AI call where your app makes it. Keep the same ID through model calls, tool calls, retries and background jobs. Then add up usage by customer for each day or month.
Can AI metering enforce usage limits?
Yes, but only if it sits in the path of your AI calls. Alerts can work from recorded usage. A hard limit that refuses a request has to run in your app or an AI gateway, before the call reaches the provider.
Can AI metering support flat-rate subscriptions?
Yes. Metering shows what each subscriber costs you even when they pay a fixed price. That tells you how much usage to include in each plan and when to charge for overage.
Put AI usage in context
See what each customer and workflow costs.
Connect AI consumption to the product decisions behind your unit economics.