> ## Documentation Index
> Fetch the complete documentation index at: https://docs.macropay.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Strategy Introduction

> Pick the right ingestion strategy to meter LLM tokens, streamed bytes, file uploads, or elapsed time — and bill on it automatically.

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](/features/usage-based-billing/event-ingestion)
in the background. You define a meter once, and metered usage starts flowing
into billing without manual bookkeeping.

<Info>
  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.
</Info>

## Choose a strategy

<CardGroup cols={2}>
  <Card title="LLM" href="/features/usage-based-billing/ingestion-strategies/llm-strategy">
    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.
  </Card>

  <Card title="Stream" href="/features/usage-based-billing/ingestion-strategies/stream-strategy">
    Wrap a Readable or Writable stream to meter bytes consumed as data flows.
  </Card>

  <Card title="S3" href="/features/usage-based-billing/ingestion-strategies/s3-strategy">
    Meter object storage — track uploads, downloads, and stored volume on S3.
  </Card>

  <Card title="Delta time" href="/features/usage-based-billing/ingestion-strategies/delta-time-strategy">
    Bill on elapsed wall-clock time between a start and a stop — compute minutes,
    sandbox sessions, render jobs.
  </Card>
</CardGroup>

## How a strategy fits together

<Steps>
  <Step title="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.
  </Step>

  <Step title="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.
  </Step>

  <Step title="Events stream to your meter">
    The helper batches and sends events off the hot path. A
    [meter](/features/usage-based-billing/meters) aggregates them, and a metered
    price turns the total into a charge.
  </Step>
</Steps>

## 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:

| Concern         | What the strategy handles                                                       |
| --------------- | ------------------------------------------------------------------------------- |
| **Measurement** | Counts tokens, bytes, or seconds at the source — no manual math.                |
| **Attribution** | Stamps every event with the `customerId` so billing lands on the right account. |
| **Throughput**  | Batches and sends in the background; your request path stays fast.              |
| **Shape**       | Emits a consistent payload your meters can aggregate without surprises.         |

## Built for AI and agent workloads

The [LLM strategy](/features/usage-based-billing/ingestion-strategies/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](/features/usage-based-billing/event-ingestion),
  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.

<Tip>
  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.
</Tip>

## 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](/features/usage-based-billing/event-ingestion) —
anything you can measure, you can meter. If your workload doesn't fit neatly,
email us at [support@macropay.ai](mailto:support@macropay.ai) and we'll help you
wire it up.
