Skip to main content
Usage-based billing only works if the usage actually reaches Macropay. The hard part is rarely the pricing — it’s the plumbing: capturing the right number, at the right moment, attributed to the right customer, without slowing down your app. Ingestion strategies are drop-in helpers that do exactly that. Each strategy wraps a piece of your stack — an LLM client, a stream, an S3 bucket, a timer — and emits structured events to the events ingestion API in the background. You define a meter once, and metered usage starts flowing into billing without manual bookkeeping.
Macropay is your Merchant of Record. Once usage is metered, we calculate the charge, collect payment, and remit the correct sales tax or VAT in every jurisdiction — so usage-based pricing never turns into a global tax project.

Choose a strategy

LLM

Wrap an @ai-sdk/* model (or a PydanticAI agent) to auto-report input, output, and cached tokens per call — the foundation for AI metered billing.

Stream

Wrap a Readable or Writable stream to meter bytes consumed as data flows.

S3

Meter object storage — track uploads, downloads, and stored volume on S3.

Delta time

Bill on elapsed wall-clock time between a start and a stop — compute minutes, sandbox sessions, render jobs.

How a strategy fits together

1

Wrap the thing you want to meter

Hand the strategy your existing client, stream, or timer. It returns an instrumented version that behaves identically to the original.
2

Run your code as usual

As your wrapped object does its work, the strategy measures the dimension you care about — tokens, bytes, seconds — and tags each event with the customer.
3

Events stream to your meter

The helper batches and sends events off the hot path. A meter aggregates them, and a metered price turns the total into a charge.

Why use a strategy instead of raw events

You can always call the ingestion API yourself. Strategies exist so you don’t have to wire up the boilerplate that surrounds every metered workload:

Built for AI and agent workloads

The LLM strategy captures token usage from a single model call — the building block for billing on usage. From there you can layer on Macropay’s AI primitives to bill on what actually matters:
  • Activity and outcomes — go beyond tokens with the Signals API, ingesting agent-attributed activity and outcome signals.
  • Margin visibility — compare billed revenue against AI cost (COGS) per agent to see your agentic margin, not just top-line usage.
Metering tokens is the easy 80%. If you’re billing autonomous agents, meter the outcome — minutes saved, tickets resolved, revenue influenced — and let token cost ride along as COGS.

Need a strategy we don’t list?

The four strategies cover the most common shapes of usage, but ingestion is just a thin layer over the events API — anything you can measure, you can meter. If your workload doesn’t fit neatly, email us at support@macropay.ai and we’ll help you wire it up.