The world’s first unified interface for agent harnessesOpen Source4.6kPowered by UHP

InsightsDec 4, 202611 min read

Usage-Based Agent APIs: How Metering, Pricing and Cost Control Work

How usage-based agent APIs meter tokens, tools and runtime, how to estimate cost per task, and how to cap spend across models and providers in production.

One agent-task capsule feeds three separate resource meters and collection chambers.
Separate meters represent the different resources a task consumes. The unnumbered channels are a conceptual billing metaphor, not measured prices or interchangeable usage units.

A usage-based agent API charges for what an agent run actually consumes (tokens, tool calls, runtime, memory) instead of a flat fee for access. For teams shipping agent-powered products, the model is the right default, because agent cost is variable by nature: one task finishes in two model calls, the next loops through forty. HarnessRouter is built on this logic: one API in front of many agent harnesses, models and sandboxes, with a published pricing structure that combines monthly plans with metered fees and no BYOK routing fee up to $25,000 a month of Model usage at listed prices; above that volume, a separate routing fee of 5% of that value applies.

This guide explains what gets metered, how providers calculate charges, how to estimate cost per task, and what to verify when an agent touches several models and providers at once.

TL;DR

  • Usage-based billing charges for measured consumption; subscriptions charge for access or an included allowance. Most agent platforms combine both.
  • Agent charges come from several meters: input, output, cached and reasoning tokens, tool calls, plus runtime, storage and memory.
  • Estimate cost per completed task, not per call: include every turn, retry and failed path, then reconcile against invoices.
  • Across multiple providers, normalize token fields and record the serving model and provider, or your totals will double-count or undercount.
  • HarnessRouter pairs plans from $0 to $1,000 per month with metered fees, and exposes supported harnesses and their compatible models and environments through one API.

What a usage-based agent API actually is

A conventional request-response API may have a simple per-request price: a request goes in, a response comes out. An agent API call starts a loop. The agent plans, calls a model, invokes a tool, reads the result, calls the model again, and repeats until the task is done or a limit stops it. The number of iterations is not known when the request is made.

That is why pricing follows consumption. Microsoft's guidance on usage-based pricing for AI describes usage-based billing as charging according to measured units such as tokens, calls or actions, while a subscription charges a recurring amount regardless of exact consumption. The same guide notes that per-request inference and orchestration costs can climb sharply for heavy users while flat-plan revenue does not, which is the core reason metering exists.

Three structures appear in practice:

StructureWhat you payFits when
Pure usage-basedMetered units onlyWorkloads are spiky or unpredictable
Subscription with allowanceRecurring fee including a usage balanceYou want a predictable baseline
HybridAccess fee plus metered usage or overageCapacity is predictable but agent actions are not

Hybrid is the common production choice. Billing platforms formalize it with meters that convert events into consumed units and allowances that grant a balance each billing period, as Paddle's usage-based billing documentation describes.

What generates usage charges

Before you can forecast anything, list the meters. Lago's agent billing guide enumerates the token metrics a billing system may track: input, output, cache-read, cache-write, reasoning, tool-call, image-input and audio input/output tokens. Microsoft separately identifies model tokens, orchestration steps, retrieval and reserved GPU capacity as distinct cost drivers.

For an agent platform, translate that into a working inventory:

  • Model tokens: the largest and most variable line. Repeated context can increase input across turns; caching changes how eligible repeated tokens are processed and priced, rather than removing them from input.
  • Cached tokens: reads are cheaper than fresh input, but writes may carry their own rate and duration.
  • Reasoning tokens: billed as output on many models even though you may not see them.
  • Tool calls: search, code execution, browser actions and any third-party API an agent invokes.
  • Runtime: time in an isolated sandbox while the agent works.
  • Storage and memory: session files and persistent agent memory, billed by storage/time or memory operations, depending on the service.
  • Observability: traces and logs, sometimes a separate line item.

HarnessRouter's published fee list mirrors this split. Agent short-term memory (Beta) is $0.0000840 per GB-hour on Free/top-up rates, with lower rates on paid plans; long-term memory is $0.0019 per operation with storage included. The pricing page lists tracing as a $50-per-month beta add-on, included with Scale, and top-up processing at 5.5% with a $0.80 minimum. Routing requests through your own provider keys carries no routing fee up to $25,000 a month of Model usage at listed prices; above that volume, a separate routing fee of 5% of that value applies. Your model provider bills you directly; Agent work and applicable memory charges still apply. Agent work is a metered fee as well; its rate is on the pricing page.

How providers measure and calculate charges

Metering reduces to one rule: charge on usage the model provider reported, not on your own estimate. Metronome's token billing guide tells integrators to send final usage only after streaming completes and the provider reports it, instead of estimating totals from partial output. Stigg's usage metering guide takes the same position: read provider-reported usage from the completed call's response and attribute it to the customer, and optionally to the agent. If a stream is interrupted before final usage arrives, mark usage as unresolved and reconcile against provider usage or billing records; missing final usage is not zero usage.

Once events exist, two pricing modes are common. In Lago's description, token mode sends normalized token counts that a customer-defined plan prices, while price mode multiplies usage by model rates and applies a markup. Token mode suits provider-neutral comparisons; price mode suits pass-through billing where you resell model usage at cost plus a margin.

A useful detail from Stigg's guide: usage numbers can be sent without prompts or model responses, so metering does not require moving sensitive content into a billing system.

Synchronous or asynchronous ingestion

The ingestion mode changes what your guardrails can see. Stigg documents asynchronous ingestion as raw per-call events and synchronous ingestion as calculated usage per metric, and recommends the synchronous path when balances must reflect each call before the next check. Asynchronous ingestion suits high-volume usage and token pass-through pricing.

The rule of thumb for agent products: if a user's credits must stop a run mid-loop, check before admitting each step. For a hard cap under concurrency, atomically reserve sufficient credits before execution, bound each call's possible spend, and reconcile actual usage afterward; synchronous ingestion alone does not reserve in-flight spend. If you only invoice monthly, asynchronous events can be enough.

Estimating the cost of one agent task

Per-call pricing tables mislead because agents do not make one call. The method that holds up is to price a task, in this order:

  1. Map the turns. For a representative task, count model calls and record input, output, cached and reasoning usage on each.
  2. Apply the rates. Normalize provider fields into non-overlapping billable buckets, then multiply each bucket by the rate for the model and provider that actually served it. Cached-input and reasoning fields can be subsets of input and output, so do not add them to their parent totals twice.
  3. Add what is billed separately. Tool calls, runtime, storage, networking and logging attributable to the task.
  4. Include the unhappy paths. Retries, failed runs and abandoned loops belong in the cost of the successful outcome.
  5. Divide by successes. Cost per completed task is the number that matters for margin.
  6. Reconcile with invoices. Cached usage, tool charges and provider pricing details can differ from a simple token calculation.

This follows the approach in FinOps AI's cost-per-task guide, which also separates marginal run cost from fully loaded cost with shared infrastructure allocated explicitly.

A worked example

Take a coding task that runs in six turns. Suppose the first turn sends 8,000 input tokens and each later turn resends that context plus new output, with 70% of repeated input served from cache. Price the actual input on every turn, including growing context, at the applicable fresh-input, cache-read and cache-write rates. Caching can reduce repeated-input cost, but six fresh 8,000-token inputs do not represent the full growing-context baseline. Now add one failed attempt that retried the whole loop. The task's real cost is the successful path plus the failed one, divided by one completed task. Numbers here are illustrative: your rates come from the provider that served each call.

Six connected trays retain a common context insert, with a separate tray for resources consumed by a failed attempt.
Six trays represent six model turns; the repeated insert remains input even when caching changes its billed treatment. The detached tray represents additional failed-attempt usage. Shapes and amounts are conceptual, not the example’s 70% cache ratio, measured costs or a refund.

The point of the exercise is the shape: turns accumulate token usage, caching can reduce repeated-input cost, and retries add the usage of whichever calls or loops are repeated. Budget for every attempt rather than a single call.

Monitoring, limiting and optimizing spend

Metering tells you what happened. Controls decide what is allowed to happen. Paddle's early-access usage billing records overage after an allowance is exhausted but does not itself block usage or bill overage; the customer decides whether to keep providing the feature. In other words, a billing system observes and your product enforces.

A workable control set for an agent product:

  • Record per call: tokens with model, run and user identifiers, so costs can be summed per run, user, agent and day, as the Promptise cost-tracking guide recommends.
  • Cap per run: a maximum number of turns, tool calls or spend per task, so a looping agent stops by design.
  • Cap per user or tenant: a balance checked with an atomic credit reservation before each step, with per-call limits where spend must halt.
  • Compare to limits daily: alerts at a fraction of budget, not at the limit.
  • Reconcile weekly: estimates against provider invoices.

Optimization comes after visibility. The levers, in rough order of effect: route each task to the cheapest model that meets the quality bar, keep stable context cacheable, trim tool output before it re-enters the context, and cap retries. Our guides on LLM cost optimization for agent teams, LLM inference costs and model routing go deeper on each. For what to trace so that cost can be attributed to a step, see AI agent observability.

If your agent product is discovered through AI assistants, you can also track LLM traffic in GA4, which helps connect acquisition channels to the usage they later generate.

Integrating usage-based billing across multiple models and providers

The hard part of metering is not one provider; it is five. Each reports usage a little differently, and the differences become billing errors.

Record the model and the provider. Metronome requires usage events to identify both, because the same model can have different prices depending on the provider serving it.

Normalize token fields. Metronome documents four principal fields: uncached input, cached input, output and cache-write tokens, and instructs integrators to normalize so each token appears in exactly one. This matters because Lago warns that subcategories behave differently by provider: cached input is a subset of input for OpenAI and Gemini but additive for Anthropic, so naively summing fields can double-count or undercount.

Match every billed field to a rate. Verify coverage for context-length tiers, service tiers, cache-write duration, audio and image rates, and tool calls. If a gateway reports only aggregate cost, it does not provide a per-field cost split; decide up front whether you meter tokens for comparison or cost for pass-through. Stigg notes that some gateways report both token counts and cost, and it keeps provider-native usage field names so you can compare against provider reports.

Check the billing rail. Stripe's LLM token billing is in public preview and available to users with a Metronome account, with new integrations directed to Metronome for pricing and usage recording. Confirm the current status before you design around it.

A unified layer removes much of this per-provider work. A unified LLM API presents one request and usage shape, and a gateway for AI API management centralizes routing, cost control and governance. HarnessRouter extends the idea one level up, from models to whole agent harnesses.

Three distinct provider records enter separate lanes and billable-category wells in a common ledger frame.
A common billing schema preserves provider identity and separates non-overlapping billable categories. Repeated shapes are conceptual categories, not equal token values, identical provider fields or comparable measured bills.

Why the harness layer changes the cost equation

Most usage-based pricing discussions stop at models. In an agent, the harness (the runtime that manages the loop, tools, context and sessions) decides how many model calls a task takes. Two harnesses given the same task and the same model can differ in turns, tool calls and context size, and therefore in cost.

That makes the harness a variable to benchmark and swap, not a fixed choice. HarnessRouter supports 30 harnesses behind one API, including Codex, Claude Code, Hermes, DeepSeek and Pi, with model, provider and environment choices subject to each harness's supported combinations. Pages such as the OpenSquilla, Continue, QwenPaw and pool harness pages distinguish available integrations from reviewed profiles; Continue, QwenPaw and pool are currently marked Reviewed. The open Unified Harness Protocol (UHP) standardizes the integration boundary for supported harnesses; UHP and MCP sit at different layers of the agent stack. For the architectural background, see AI agent architecture, AI agent integration and how an agent SDK, a managed agent and an agent CLI differ.

Our perspective

We built HarnessRouter on one observation: agent cost is decided by combinations, not by a single price. The harness, the model, the provider and the sandbox each change what a task consumes, and a team that hardcodes any one of them also hardcodes its cost curve.

That is why we treat supported parts of an agent system as configurable building blocks, and why our interface helps teams compare configurations for each task on quality, latency or cost. Our aim is to cut agent costs by more than 90%, and the route there is measurement: when harnesses, models and modules sit behind one API, they can be benchmarked against each other on your own tasks instead of on a vendor's marketing page.

Our pricing follows the same principle. Plans provide included usage, and metered consumption draws from that allowance or top-up credit, and bringing your own provider keys carries no routing fee up to $25,000 a month of Model usage at listed prices, with a separate routing fee of 5% of that value above that volume. You pay model providers at their rates and keep control of the relationship. Because UHP is open, the harness layer becomes commodity infrastructure rather than a source of lock-in.

Choosing a plan and starting small

HarnessRouter's published plans are Free at $0 per month, Developer at $20 per month, Production at $200 per month and Scale at $1,000 per month, with Enterprise available without a published price. Agent work and memory usage draw from included usage or top-up credit; tracing is a beta add-on included with Scale, and top-up processing is transaction-based. A sensible path: prototype on the Free plan, instrument cost per task against your own workload, and move up when volume and tracing needs justify it. Teams that prefer to run their own infrastructure can use the open-source HarnessRouter Community Edition. The product-integration walkthrough is in our AI agent API guide, and the operational view is in AI agents in production.

If you are ready to run agents through one API with metered cost, see the plans on the pricing page.

HarnessRouter

The Developer plan is the usual starting point for teams moving from a prototype to a first production feature, and the BYOK option keeps your existing provider contracts intact.

FAQ

What is the difference between a usage-based agent API and a subscription?

A usage-based API bills on measured consumption such as tokens, tool calls or runtime. A subscription bills a recurring amount for access or an included allowance. Many platforms combine them: a plan for the baseline and metered usage for what varies.

What counts as usage in an agent run?

Input, output, cached and reasoning tokens, tool calls, and image or audio tokens can all be metered, as Lago's billing guide lists. On the platform side, runtime, storage and memory add their own lines.

How do I estimate what one task will cost?

Price every turn of a representative run with the rates of the provider that served it, add separately billed tools and runtime, include retries, and divide by completed tasks. Then compare the estimate with your invoice and adjust.

How do I stop an agent from overspending?

Set limits in your own product: a turn and spend cap per run, a balance check per user, and alerts before the budget is hit. Billing systems record usage and overage; enforcement is a product decision. Check before each step, use atomic credit reservations and per-call limits for concurrent hard caps, and reconcile actual usage afterward.

Sources

→Next

Keep Agent Costs in View

HarnessRouter brings supported harnesses and compatible models, providers and environments together through one API, so teams can compare configurations for quality, latency or cost.