← All posts

AI agents are eating software. But the billing infrastructure built for SaaS subscriptions and per-seat pricing wasn't designed for autonomous systems that run thousands of times a day, consume variable compute per run, and succeed or fail in ways that matter to the customer. This guide covers what actually works.

Why AI agents break traditional billing

Traditional software has predictable resource consumption. A project management app costs roughly the same to serve per user per month. You charge a seat fee, cover your costs, take your margin. Done.

AI agents are different in three ways that matter for billing:

Token-based vs outcome-based pricing

Two models have emerged as viable. Here's how to think about them:

ModelBest forRisk
Token-based Predictable workloads, developer tools, internal tooling Customers don't understand tokens; friction at sale
Outcome-based Customer-facing agents, workflow automation, revenue-generating actions Requires reliable outcome detection; disputes on edge cases
Hybrid (base + token + outcome bonus) Most production use cases More complex to explain; worth it for conversion

The hybrid model is what Rev uses internally and recommends to most builders. You charge a small base fee per API call (covers your fixed overhead), add a token component (covers compute), and add an outcome bonus only when the agent delivers a result the customer cares about. The base + token floor ensures you're never underwater on a run; the outcome bonus aligns incentives.

Concrete example: An AI email outreach agent charges $0.005/call base + $0.0001/token + $2.50/positive reply detected. At 1,000 calls with 10 replies, the customer pays ~$30 in base+token fees and $25 in outcome fees — $55 total for 10 verified warm leads. That's $5.50/lead at scale. Customers will pay this. They won't pay $0.055/email flat-rate because they can't see the value-per-dollar.

How metering actually works

Metering is the infrastructure layer that sits between your agent and your billing system. It captures four things per agent execution:

  1. Agent ID — which agent triggered the event
  2. Action — what the agent did (e.g., email.sent, calendar.booked)
  3. Token count — input + output tokens consumed
  4. Outcome — success/failure/pending, with a result payload your pricing engine evaluates

Here's a minimal meter call using the Rev API:

curl bash
curl -X POST https://rev.polsia.app/v1/meter \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "outreach-agent-v2",
    "action": "email.sent",
    "tokens_input": 1200,
    "tokens_output": 340,
    "outcome": "success",
    "metadata": {
      "recipient": "prospect@company.com",
      "campaign": "q2-enterprise"
    }
  }'

Same call in Node.js:

Node.js javascript
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: 1200,
    tokens_output: 340,
    outcome: 'success',
    metadata: {
      recipient: 'prospect@company.com',
      campaign: 'q2-enterprise'
    }
  }),
});

const { price_charged, outcome_id } = await response.json();
console.log(`Charged: ${price_charged}`);

And in Python:

Python python
import requests

response = requests.post(
    'https://rev.polsia.app/v1/meter',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
    },
    json={
        'agent_id': 'outreach-agent-v2',
        'action': 'email.sent',
        'tokens_input': 1200,
        'tokens_output': 340,
        'outcome': 'success',
        'metadata': {
            'recipient': 'prospect@company.com',
            'campaign': 'q2-enterprise'
        }
    }
)

data = response.json()
print(f"Charged: ${data['price_charged']}")

The API returns a price_charged value (computed from your pricing tier configuration) and an outcome_id you can use to resolve deferred outcomes — when your agent can't immediately confirm success, you register the call as "pending" and resolve it later via a webhook or manual API call.

Deferred outcomes: the pattern most builders miss

Not every agent action has an immediate, detectable outcome. An email gets sent — did the prospect reply? A meeting invite fires — did the contact accept? An order gets placed — did it ship successfully?

The naive approach is to assume success and charge upfront. This creates disputes and erodes trust. The correct approach is deferred outcome resolution:

Deferred outcome pattern javascript
// Step 1: Register the call as pending
const { outcome_id } = await revgrid.meter({
  agent_id: 'email-agent',
  action: 'email.sent',
  tokens_input: 800,
  tokens_output: 220,
  outcome: 'pending',
  expires_at: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // 7 days
});

// Step 2: When you detect a reply (via webhook, polling, etc)
await revgrid.resolveOutcome(outcome_id, {
  outcome: 'success',
  metadata: { reply_received: true, reply_at: new Date() }
});
// The outcome bonus is charged only now

Rev's pricing engine handles this natively — pending outcomes don't charge the outcome bonus until resolved, and expired outcomes fall back to a configurable default (usually just the base + token fee).

Build vs buy: what actually matters

Every team that builds their own metering regrets it by month 3. Here's the honest breakdown:

ConcernBuild yourselfRev
Time to first meter call 2–4 weeks (schema, API, reliability) 30 minutes
Outcome bonus logic Custom code per use case Config-driven per pricing tier
Deferred outcomes Build queue, expiry, resolution Built in
Revenue analytics Build dashboards Real-time dashboard included
Stripe integration Months of work Done
What you're actually building Billing infrastructure Your AI agent

The argument for building: full control, no vendor dependency, no revenue share. Valid if you're at scale with a dedicated platform team. At early stage, you're trading engineering time that should go into your core product for infrastructure that's been solved.

The Rev approach

Rev exposes metering, pricing configuration, and outcome resolution as a single API. You define your pricing tiers (base fee, token rate, outcome bonus conditions), call /v1/meter after every agent execution, and the engine handles the math, the storage, and the Stripe billing.

Three things worth knowing:

Ready to meter your first agent?
Get your API key and make your first /v1/meter call in under 5 minutes. Get Your API Key →

What to read next

If you're building an AI agent that needs billing, the fastest path is:

  1. Read the API docs — 10 minutes to understand the full surface area
  2. Run the pricing simulator with your expected volume
  3. Get your API key and make a test meter call
  4. Wire your agent to call /v1/meter after every execution

The first three steps take under 30 minutes. The fourth is one line of code.