0Pricing
AI Powered SaaS: Stripe + Auth + Billing + Deploy · Lesson

Metered Billing & Usage-Based Pricing

Charge customers for what they actually use by reporting usage to Stripe, configuring metered prices, and building usage-based tiers for your AI SaaS.

Metered Billing & Usage-Based Pricing is a free AI Powered SaaS: Stripe + Auth + Billing + Deploy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AI Powered SaaS: Stripe + Auth + Billing + Deploy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Usage-Based Pricing?

Flat subscriptions do not fit products where cost scales with consumption — like AI tokens or API calls. Metered billing charges customers for actual usage, aligning revenue with cost.

Licensed vs Metered Prices

Stripe prices come in two usage types:

  • Licensed: a fixed quantity (e.g. 5 seats)
  • Metered: quantity reported over time and billed at period end

Creating a Metered Price

Define a recurring price with usage_type: metered. Stripe sums reported usage for each billing cycle.

await stripe.prices.create({
  product: productId,
  currency: 'usd',
  recurring: { interval: 'month', usage_type: 'metered' },
  unit_amount: 2
});

Subscribing Without a Quantity

For metered items you do not set a quantity at subscription time — Stripe learns it from usage reports.

await stripe.subscriptions.create({
  customer: customerId,
  items: [{ price: meteredPriceId }]
});

Reporting Usage

As customers consume the product, report usage against the subscription item. Use action: increment to add to the running total.

await stripe.subscriptionItems.createUsageRecord(itemId, {
  quantity: 1000,
  timestamp: Math.floor(Date.now() / 1000),
  action: 'increment'
});

When to Report

Report at the moment usage happens — for example, after each AI completion count its tokens. Buffer high-frequency events and flush periodically to avoid hitting API limits.

async function onAiCall(itemId, tokens) {
  await reportUsage(itemId, tokens);
}

Idempotent Reporting

Avoid double-counting on retries by sending an idempotency key. Stripe ignores duplicate requests with the same key.

await stripe.subscriptionItems.createUsageRecord(
  itemId,
  { quantity: 1000, action: 'increment' },
  { idempotencyKey: 'usage-' + eventId }
);

Tiered Pricing

You can combine metering with tiers: the first 10,000 units cost more per unit, additional units less. Stripe computes the blended total automatically.

recurring: { usage_type: 'metered' },
billing_scheme: 'tiered',
tiers_mode: 'graduated'

Showing Usage to Customers

Customers want transparency. Fetch the current period's usage and display it in their dashboard so there are no billing surprises.

const summaries = await stripe.subscriptionItems.listUsageRecordSummaries(itemId);

Combining Plans

Many SaaS use a hybrid model: a fixed monthly base fee (licensed) plus metered overage. Add both prices as separate items on one subscription.

items: [
  { price: baseFeePriceId },
  { price: meteredPriceId }
]

Best Practices

Run metered billing reliably:

  • Use metered prices for consumption-based products
  • Report usage with increment and idempotency keys
  • Consider tiered pricing for volume
  • Show usage to customers for transparency

Quick Check

Test your metered billing knowledge.

Recap

You added usage-based billing:

  • Create metered prices and subscribe without a quantity
  • Report usage with increment and idempotency keys
  • Use tiered pricing and hybrid base-plus-overage models
  • Surface usage to customers for transparency

Your AI SaaS now charges fairly for what users consume.

Frequently asked questions

Is the “Metered Billing & Usage-Based Pricing” lesson free?

Yes — the full text of “Metered Billing & Usage-Based Pricing” is free to read here on the web, and the AI Powered SaaS: Stripe + Auth + Billing + Deploy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AI Powered SaaS: Stripe + Auth + Billing + Deploy course, upgrade to CoddyKit PRO.

What will I learn in “Metered Billing & Usage-Based Pricing”?

Charge customers for what they actually use by reporting usage to Stripe, configuring metered prices, and building usage-based tiers for your AI SaaS. You practise AI Powered SaaS: Stripe + Auth + Billing + Deploy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AI Powered SaaS: Stripe + Auth + Billing + Deploy?

No prior experience is required. AI Powered SaaS: Stripe + Auth + Billing + Deploy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Metered Billing & Usage-Based Pricing” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AI Powered SaaS: Stripe + Auth + Billing + Deploy lesson?

Yes. Every AI Powered SaaS: Stripe + Auth + Billing + Deploy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Subscription Management
  2. Handling Stripe Webhooks
  3. Customer Portal & Billing History
  4. Metered Billing & Usage-Based Pricing
← Back to AI Powered SaaS: Stripe + Auth + Billing + Deploy