Macropay is a Merchant of Record. When a customer pays for your AI product, we are the legal seller, so we calculate and remit sales tax and VAT worldwide, keep you off the hook for that liability, and stay PCI DSS Level 1 compliant. You ship the product; we handle the money, the tax, and the compliance.
What “billing for inference” actually requires
Before picking an approach, it helps to see the full surface area. Charging for LLM usage means owning all of this:
Whoever owns that last row is the merchant of record. With a DIY stack, that’s you. With Macropay, that’s us.
Approach 1 — Build it yourself
The do-it-yourself route is a real option, and for some teams the right one. Here’s the shape of what you’re signing up for.- A usage table keyed by customer, with tokens, model, and cost on every event
- An aggregation layer that computes usage per customer per billing period
- A pricing engine that applies your markup and produces a charge
- A payment integration to actually collect — plus retries and dunning
- A customer-facing view of usage and estimated charges
Three traps teams hit
Provider schemas don't agree
Provider schemas don't agree
OpenAI returns
usage.prompt_tokens and usage.completion_tokens. Anthropic returns usage.input_tokens and usage.output_tokens. Google returns usageMetadata.promptTokenCount. Support more than one model and you’ve built a normalization layer whether you wanted to or not.Disputes demand an audit trail
Disputes demand an audit trail
When a customer challenges a charge, “trust me, you used 4.2M tokens” doesn’t hold up. You need per-request logs you can point to — not just monthly aggregates — which means storing and querying detail at scale.
Cost and price are two different ledgers
Cost and price are two different ledgers
What you paid the model provider and what you charge the customer are separate numbers. Margin lives in the gap, and you can’t see it without tracking both — a second accounting layer most teams discover late.
Approach 2 — Run it on Macropay
Macropay is usage-based billing infrastructure built for AI products. You instrument your LLM calls with the@macropayments/ingestion SDK; we handle metering, aggregation, invoicing, collection, tax, and the customer portal.
Step 1 — Install the SDK
Step 2 — Wrap your model with the LLM ingestion strategy
The strategy intercepts each call and records token counts, model, and your cost automatically — attributed to the customer who made the request. TypeScript (Vercel AI SDK)- Input, output, and cached token counts
- Model name and provider
- Your cost for the request
- The customer it belongs to
Step 3 — Create a meter
A meter turns raw events into a billable quantity. For token billing, sumtotalTokens from your ingestion events.
1
Open Usage Based Billing in the dashboard
Go to the Meters section and choose Create Meter.
2
Configure the meter
- Name: LLM Tokens
- Filter: events named
research-query - Aggregation: sum of
metadata.totalTokens
3
Attach a metered price to your product
Add a metered price to the product — for example, $0.01 per 1,000 tokens.
Step 4 — Customers watch it update live
Usage and estimated charges appear in the self-serve customer portal and refresh as events arrive — so the invoice is never a surprise.Setting your margin
Capturing usage is the easy half. Choosing what to charge is where products win or lose. Three patterns cover most AI businesses.Flat markup
Add a fixed percentage on top of your model cost. Easy to reason about, easy to explain — but your margin moves whenever the provider’s pricing does.Volume tiers
Lower the per-token rate as usage climbs, which rewards your biggest customers for consolidating spend with you. Configure the tiers directly on the metered price — no custom code.Prepaid credits
Sell credits up front and burn them down per request. You get predictable revenue; the customer gets a price that’s easy to budget against. Grant a credit allotment with each tier using the meter credits benefit.Beyond tokens: billing agents on outcomes
Tokens are the obvious meter, but they measure your cost, not the value a customer receives. If you ship autonomous agents, Macropay lets you bill on what the agent did or achieved — not just what it consumed.- Activity and outcome signals. Send
POST /v1/signalsto record agent activity (a research run, a ticket resolved) or an outcome (a meeting booked, a refund prevented), attributed to the agent that produced it. - Value receipts. Certify ROI — time saved, revenue generated, cost avoided — so a customer sees the value behind the invoice, not just the line item.
- Agentic margin. Compare billed revenue against the AI cost (COGS) behind each agent, so you know which agents actually earn their keep.
Worked example: an AI writing tool
Here’s the whole thing end to end for a tool that drafts blog posts, emails, and marketing copy. The model: a monthly subscription with included credits and metered overage. Plans
Implementation
- Meters tokens per customer
- Draws down the included credits on their tier
- Bills overage at the right tier rate
- Issues the invoice each period and collects the payment
- Remits sales tax and VAT in every market you sell to
- Surfaces live usage in the customer portal
Know your margins in real time
Pricing isn’t set-and-forget — upstream model costs drift, and a power user who was profitable in January may not be in June. Cost Insights puts your upstream LLM spend next to customer revenue so you can answer:- Gross margin per customer — are your heaviest users still in the black?
- Cost trend — is a provider price change quietly eating your margin?
- Model efficiency — which model gives the best margin for this workload?
Start here
Create your account
Sign up and ship a metered product in under ten minutes.
Usage-based billing
Events, meters, and metered pricing, explained.
LLM ingestion strategy
SDK reference for capturing token usage and cost.
Cost Insights
Track upstream costs and watch margins live.