Blog
The Full Playbook: How to Design Usage-Based Pricing Models

The Full Playbook: How to Design Usage-Based Pricing Models

Usage-based pricing is now the standard for SaaS and AI monetization, with over 60% of companies adopting it. This shift is driven by AI's variable costs, customer "subscription fatigue", and a focus on margins that make traditional per-seat models obsolete.

For developers, this new paradigm is complex. Implementing usage-based pricing is technically demanding, requiring precise metering, flexible pricing logic, and solid billing automation to prevent revenue leakage and customer frustration. This guide helps engineers design a developer-friendly usage model and build a scalable billing system to support it.

What Is Usage-Based Pricing?

Usage-based pricing (UBP) charges customers based on their consumption of a product or service—such as API calls made, data processed, or gigabytes stored. Unlike flat-rate subscriptions, cost is tied directly to value, and a vendor's revenue scales with customer usage.

UBP works best when usage correlates strongly with customer value and the vendor's costs. It's common for cloud infrastructure, AI, and API-driven software but less so for apps where users don't perceive incremental value from each action. Many companies blend UBP with subscriptions to balance flexibility and predictability.

When it comes to implementation, billing often becomes a nightmare for engineers. Here’s why:

The Hidden Headaches of Building Billing In-House

#1 — Dates: Where Complexity Hides in Plain Sight

Leap years. Proration. Anniversary versus calendar billing. Trial logic. What begins as a single start_date field quickly sprawls into dozens of logic branches—and just as many support tickets.

#2 — Plan Changes: Downgrade One Feature, Trigger Five Bugs

  • Mid-period switches from prepaid to postpaid plans
  • Prorating accurately across plan tiers and timeframes
  • Discounts that must persist, adjust, or expire

You can sketch these scenarios in five minutes. But implementing them? That’s weeks of work—and tests.

#3 — Usage-Based Billing: Trivial Until You Hit Scale

Counting API calls or active users sounds easy—until you're processing millions of events a day. Tracking usage accurately, resetting counters monthly, and applying business logic at scale is not just an engineering challenge, it’s a data pipeline.

#4 — Idempotency: Don’t Charge Twice, Don’t Miss Revenue

You have to support retries, replays, and race conditions without double billing—or missing charges. The concept of idempotency is simple. Guaranteeing it across distributed systems, over time, under pressure? Not so much.

#5 — Cash Collection: The Most Expensive Missed Step

Failed payments mean more than missed revenue—they mean workflows: email reminders, access suspension, retries, reconciliations. Every broken payment path is a leak in your funnel and a job for someone to fix. Eventually, someone jokes about hiring a Chief Waiting Funds Officer—and they’re only half joking.

#6 — Taxes: Nothing Is Ever Standard

Which rates apply? Where? To what product? For which customer? Are they tax-exempt? What if the rate just changed? What if this feature shouldn’t be taxed? What if you’re in 100 countries? You get the idea.

Build Product, Not Plumbing

These examples are just the start. A custom billing system means keeping pace with tax law, time zones, currencies, proration logic, customer complaints, and security reviews. Tools like Lago exist so your team can focus on what makes your product great—not the infrastructure that gets you paid.

Usage-Based Pricing Models: Examples and Use Cases

Understanding these five common models will help you build the right billing logic and data flows.

1. Pay-Per-Use (Pure Consumption) – Example: AWS

Customers pay only for what they consume, with no base fee. Cloud providers like AWS bill for the exact gigabyte of storage or hour of compute used. Twilio charges per SMS sent, and AI APIs charge per token processed.

  • Benefits: Offers maximum transparency and aligns revenue directly with your costs, creating a built-in expansion mechanism.
  • Downsides: Can create bill uncertainty for customers and less predictable revenue for the business. It demands a highly robust metering infrastructure where every event is accurately billed.
  • Developer Notes: This model requires real-time, high-throughput event processing. Lago provides a high-throughput events API and ensures idempotency to prevent over-billing. Implement usage alerts and caps to prevent runaway costs.

2. Credit-Based Pricing – Example: Relevance AI

Customers buy a bundle of credits (often via subscription) that they spend to use the product. If credits run out, they must buy more or wait for the next cycle. This is very popular for generative AI apps.

  • Benefits: Combines subscription predictability with usage flexibility. Customers know their upfront cost, avoiding surprise bills, while vendors secure recurring revenue.
  • Downsides: Can confuse users if the credit-to-usage conversion isn't clear. It also introduces margin variability from under-utilized or fully depleted credits.
  • Developer Notes: Requires a wallet or balance tracking system with atomic operations to prevent race conditions. You need logic for when a balance hits zero (hard cap or auto top-up). The Lago platform natively supports prepaid credits, automatically deducting usage from balances and handling top-ups.

3. Percentage-Based Pricing – Example: Stripe

Pricing is a percentage of a metric, usually revenue—a commission model. Stripe charges ~2.9% of the transaction volume it processes. This model is rare, as it requires access to a clear value metric like revenue or savings.

  • Benefits: Deeply aligns with customer success—you only make money when they do. This can simplify sales and lower the entry barrier for small customers.
  • Downsides: Revenue is not guaranteed and depends entirely on customer performance. Larger customers may balk at high fees at scale and demand discounts.
  • Developer Notes: Often requires integrating with external financial systems to obtain and verify the base metric. Transparency is key, so build reports showing how the charge was computed.

4. Outcome-Based Pricing – Example: Chargeflow

A "no cure, no pay" model where customers are charged only when a specific, successful outcome is achieved. For example, Chargeflow charges a percentage of recovered funds only when it successfully reverses a chargeback.

  • Benefits: An easy sell, as cost is directly tied to a positive ROI. If the tool doesn't work, the customer pays nothing.
  • Downsides: Can be difficult to implement. Both parties must agree on how to define, measure, and attribute the outcome, creating a risk of disputes.
  • Developer Notes: Requires an event-driven architecture where a "success event" triggers a billing action. Your billing system must support irregular, one-off charges that may not align with a monthly cycle.

5. Hybrid Pricing Models – Examples: Supabase

This common approach blends a subscription base fee (which includes a usage quota) with overage charges for higher consumption. Supabase, for instance, includes storage and bandwidth in its monthly fee, then charges for usage beyond those amounts.

  • Benefits: Offers the "best of both worlds": predictable revenue from the base fee and scalable upside from usage charges.
  • Downsides: Can become complex to communicate. Customers might feel it's unfair to pay a subscription and usage fees on top.
  • Developer Notes: Requires flexible billing logic to track usage against included quotas and apply overage rules. You must handle proration if customers upgrade mid-cycle. Lago handles both recurring charges and metered overages, and automatically manages proration for plan changes.

Choosing the Right Usage Metric

Your billable metric is a foundational decision. It must be:

  1. Correlated with your costs: Ensure your pricing scales with your expenses to protect margins.
  2. Aligned with customer value: Charge for something that clearly reflects the benefit customers receive. Avoid abstract metrics.
  3. Good for UX: Don't meter actions in a way that discourages natural product use.
  4. Clear and intuitive: Customers should easily understand what they are paying for.

PostHog, for example, charges for events recorded or sessions replayed—metrics that are intuitive and clearly tied to value.

Key Elements of a Usage-Based Pricing Strategy

How you structure charges impacts user acceptance, revenue predictability, and technical implementation.

  • Base Fee vs. Usage-Only: A base fee with included usage provides a predictable revenue floor. Pure usage-only billing maximizes alignment with consumption but makes revenue more variable.
  • Included Usage (Entitlements): The amount of usage included in a plan is a strategic decision. Technically, this requires resetting an allowance each billing period and tracking usage against it before counting overages.
  • Overage Pricing and Policies: When usage exceeds a plan's quota, you can either bill for the excess units at a predefined rate or enforce a hard cap that prompts an upgrade. Overages can cause bill shock if not handled carefully. In Lago, you can set up progressive invoicing rules to bill immediately if usage fees cross a certain threshold.
  • Prepaid vs. Postpaid Billing: Prepaid models (e.g., credits) mean customers pay upfront, eliminating payment risk. Postpaid models mean you bill after usage, which is simpler for customers but introduces risk. Lago supports both prepaid wallets and postpaid metered billing out of the box.
  • Tiered Pricing and Packaging: Tiers segment your market by bundling features with different usage limits and rates. This requires a billing engine that supports conditional pricing rules and feature entitlements based on a customer's plan.

User-Facing Features to Build for UBP

Pricing is a product feature. Build trust and reduce support load with these components:

  • Live Usage & Billing Dashboard: Show customers their real-time usage, quota, and estimated bill. This transparency builds trust. With Lago, you can query usage via API or use webhooks to power a live dashboard.
  • Self-Service Customer Portal: Allow customers to manage their subscription, download invoices, and update payment info. Lago offers a pre-built, embeddable customer portal to handle this.
  • Real-Time Usage Alerts: Notify users via email or Slack when they approach usage limits to prevent surprise bills. Alerts can be informational or trigger hard caps.
  • Clear, Itemized Invoices: Invoices should clearly itemize each charge. Programmatically generating detailed PDF invoices is a must. A system like Lago generates these automatically, with clear itemization and tax handling.

Under the Hood: Building a Usage-Based Billing System

Building a billing system is a major engineering effort. Whether you build or buy, address these core components.

1. Reliable Usage Event Collection (Metering)

Capture every billable action as a usage event with metadata (customer ID, timestamp, quantity). Use a robust events pipeline. Lago’s API can ingest up to 15,000 events per second and ensures idempotency with a unique transaction_id for each event, preventing double billing.

2. Aggregating Events into Billable Metrics

Raw events must be aggregated into the metrics you bill on (e.g., summing API calls per month). Lago supports various aggregation types like COUNT, UNIQUE COUNT, SUM, and MAX, and even allows custom SQL for complex metrics.

3. Pricing Logic and Rate Plans

Apply your pricing rules to the aggregated metrics. This logic can range from a flat rate to complex tiered or volume-based structures. Lago supports all modern pricing models declaratively through its API or UI, including subscriptions, tiered pricing, and prepaid credits. For price estimation, Lago’s API has an endpoint to calculate an upcoming fee for a given usage input.

4. Invoice Generation and Payment Integration

At the end of a billing period, generate an invoice detailing all charges, credits, and taxes. This process must be automated. Lago’s invoice engine consolidates all data to output a finalized invoice, handling proration and taxes automatically. Then, integrate with a payment processor to collect payment.

5. Scaling, Testing, and Monitoring

Treat your billing system as critical infrastructure. Ensure it can scale, create tests to verify its accuracy, monitor its performance, and keep an audit log of all changes.

Conclusion: Focus on Building Your Product, Not Reinventing Billing

Usage-based pricing unlocks growth but is complex to engineer. Building a custom billing system can divert your best engineers for months or years.

This is the problem we built Lago to solve. Lago is an open-source, API-first billing platform that gives you the control of a custom system without the maintenance burden. It supports all the models in this guide, from simple subscriptions to complex hybrid plans. Being open-source, it's flexible and never a black box.

By leveraging a solution like Lago, you can save months of engineering effort and focus on your core product, confident that your billing can handle any pricing strategy you dream up.

About Lago

We started Lago because we understand the pain of billing. For our co-founder Raffi, building billing was supposed to be a short sprint with a single engineer. It ballooned into an ongoing team of 10 full-time engineers.

If you’ve read this ebook, you now understand the complexity of billing. Each individual part might not be difficult. But if you aggregate all of the parts, the system becomes difficult to maintain.

We built Lago as a plug-and-play billing system that’s as flexible as if you’ve built it yourself, but doesn’t come with the maintenance work of a homegrown system (nor the surprise edge cases).

Lago supports every pricing model and feature in this ebook natively so you can just focus on building.

Under the hood it ingests up to 15,000 billing events per second, lets you mix pay-as-you-go, hybrid or prepaid plans in minutes, and auto-generates tax-ready invoices, credits and one-off charges so revenue keeps flowing while you keep building.

Want to give Lago a try? Schedule a demo with our team today.

Last updated on:
August 5, 2025

Focus on building, not billing

Whether you choose premium or host the open-source version, you'll never worry about billing again.

Lago Premium

The optimal solution for teams with control and flexibility.

lago-cloud-version

Lago Open Source

The optimal solution for small projects.

lago-open-source-version