How to Build a Usage-Based Billing System for AI Agents
Step-by-step guide: instrumentation, metering strategy, billing pipeline, edge cases, and scale considerations — with working code.
Rev gives your AI agents a metering API, outcome-based pricing engine, and Stripe billing — in one integration. Stop building billing infrastructure. Start billing.
Rev sits between your AI agent execution and your Stripe account. It meters every call, computes the right price based on your pricing config, and handles the billing — automatically.
Track agent_id, action, tokens consumed, and outcome on every call. Build a revenue audit trail without lifting a finger.
Configure base fee + per-token rate + outcome bonus per pricing tier. Rev computes the price on every meter call — no backend logic needed.
Charge base fee now, outcome bonus when the result lands. Booked meeting, qualified lead, resolved ticket — only charge when it actually happens.
Per-customer usage dashboard, daily revenue breakdown, token consumption trends. Know what's working before month end.
One POST after your LLM call. That's it.
// After your LLM call — add this to start billing const response = await fetch('https://rev.polsia.app/v1/meter', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json', }, body: JSON.stringify({ agent_id: 'outreach-agent-v2', action: 'email.sent', tokens_input: llmResponse.usage.prompt_tokens, tokens_output: llmResponse.usage.completion_tokens, outcome: 'success', metadata: { customer_id: input.customerId, campaign: 'q2-outreach', }, }), }); const { price_charged } = await response.json(); // price_charged = base fee + token rate + outcome bonus console.log(`Charged: $${price_charged}`);
Stripe for billing, webhooks for events, REST API for everything else. No surprises.
Customers subscribe to your Rev pricing tier via Stripe Checkout. Rev reports usage to Stripe each billing period — metered billing handled automatically.
Register webhook endpoints to receive meter events and outcome resolutions. Build custom billing logic, sync to your own DB, or trigger downstream workflows.
Meter, resolve outcomes, fetch analytics, manage pricing tiers — all via REST. SDKs available for Node.js and Python.
Include an Idempotency-Key header on any meter call. Rev deduplicates automatically — safe to retry on network failure without worrying about duplicate charges.
No sales call, no approval process. Get your key, make your first call, start billing.
Sign up and your API key is in your inbox instantly. No credit card required. Free tier includes 1,000 meter calls/month.
After every LLM call, fire a meter event to Rev. Include tokens, outcome, and metadata. Rev computes the price and stores the record.
Open the dashboard to see live usage, per-customer breakdowns, and daily revenue. Connect Stripe to start collecting actual payments.
Long-form technical content from the Rev team — metering patterns, pricing models, and build vs buy analysis.
Step-by-step guide: instrumentation, metering strategy, billing pipeline, edge cases, and scale considerations — with working code.
Per-token vs per-call vs outcome-based: pros, cons, and real code examples. Decision framework for picking the right model.
Every endpoint documented: /v1/meter, /v1/outcomes/:id/resolve, /v1/analytics, webhooks, and error codes.
View docs →5-minute integration walkthrough. Get your API key, make your first call, see revenue in the dashboard.
Start now →Fire live API calls in the browser. See real price computations for all three pricing models — no account needed to try.
Try the sandbox →Stop rebuilding what Rev already built. One integration gets you metering, pricing, outcomes, and Stripe — production-ready today.
Have a question about integration, pricing, or a specific agent architecture? Send us the details and we'll reply within one business day.
Your message landed in our inbox. Expect a reply from a real person on the Rev team within 24 hours.