Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Developer tools
Get started
Payments
Finance automation
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Overview
Billing
    Overview
    About the Billing APIs
    Subscriptions
    Invoicing
    Usage-based billing
      Choose a usage-based billing setup
        Use products and prices
          Manage billing setup
          Transform quantities
        Use rate cards
      Record usage for billing
      Offer billing credits
      Monitor usage
      Usage-based pricing models
    Connect and Billing
    Tax and Billing
    Quotes
    Revenue recovery
    Automations
    Scripts
    Revenue recognition
    Customer management
    Entitlements
    Test your integration
Tax
Reporting
Data
Startup incorporation
HomeFinance automationBillingUsage-based billingChoose a usage-based billing setup

Set up usage-based billing with products and prices

Charge customers based on their usage of your product or service.

Copy page

Usage-based billing enables you to charge customers based on their usage of your product or service.

This guide demonstrates how to create a meter, set up pricing and billing, and send meter events to record customer usage using Products and Prices. You’ll learn core concepts of a usage-based billing model through a fictional GenAI company called Alpaca AI. Alpaca AI charges their customers 0.04 USD per hundred tokens, and bills them at the end of the month in arrears.

Here’s what the lifecycle looks like for a typical usage-based billing integration that uses products and prices:

Create a meter

Meters specify how to aggregate meter events over a billing period. Meter events represent all actions that customers take in your system (for example, API requests). Meters attach to prices and form the basis of what’s billed.

For the Alpaca AI example, meter events are the number of tokens a customer uses in a query. The meter is the sum of tokens over a month.

You can use the Stripe Dashboard or API to configure a meter. To use the API with the Stripe CLI to create a meter, get started with the Stripe CLI.

  1. On the Meters page, click Create meter.
  2. On the Create meter page, do the following:
    • For Meter name, enter the name of the meter to display and for organization purposes. For the Alpaca AI example, enter “Alpaca AI tokens.”
    • For Event name, enter the name to display in meter events when reporting usage to Stripe. For the Alpaca AI example, enter “alpaca_ai_tokens.”
    • Select Sum from the Aggregation method dropdown to set the aggregation formula.
    • Click Create meter.

Create a pricing model

Use the Stripe Dashboard or API to create a pricing model that includes your Products and their pricing options. Prices define the unit cost, currency, and billing cycle.

For the Alpaca AI example, you create a product with a metered price of 0.04 USD per hundred units, billed at a monthly interval. You use the meter that you created in the previous step.

  1. On the Product catalog page, click Create product.
  2. On the Add a product page, do the following:
    • For Name, enter the name of your product. For the Alpaca AI example, enter Alpaca AI.
    • (Optional) For Description, add a description that appears at checkout in the customer portal and in quotes.
    • Select Recurring.
    • Under Billing period, select More pricing options.
  3. On the Add price page, do the following:
    • Under Choose your pricing model, select Usage-based and Per package.
    • Under Price, set the Amount to 0.04 USD per 1000 units.
    • Under Meter, select Alpaca AI tokens from the dropdown.
    • Under Billing period, select Monthly.
    • Click Next.
  4. On the Add a product page, click Add product.

Create a customer

Next, create a customer.

  1. On the Customers page, click Add customer.
  2. On the Create customer page, do the following:
    • For Name, enter the name of your customer. For the Alpaca AI example, enter John Doe.
    • (Optional) Add an email address and description for your customer.
    • Click Add customer.

Create a subscription

Subscriptions allow you to charge recurring amounts by associating a customer with a specific price.

Use the Stripe Dashboard or API to create a subscription that includes your customer, product, and usage-based price.

For the Alpaca AI example, you create a subscription for the Alpaca AI product, with a metered price of 0.04 USD per unit, billed monthly to John Doe.

Note

You can associate a single metered price with one or more subscriptions.

  1. On the Subscriptions page, click Create test subscription.
  2. On the Create a test subscription page, do the following:
    • Under Customer, select the name of your customer. For the Alpaca AI example, select John Doe.
    • Under Product, select your price. For the Alpaca AI example, select the price under Alpaca AI.
    • (Optional) Modify the subscription details and settings as needed.
    • Click Create test subscription.

Send a test meter event

Use Meter Events to record customer usage for your meter. At the end of the billing period, Stripe bills the reported usage.

You can test your usage-based billing by sending a meter event through the Stripe Dashboard or API. When using the API, specify the customer ID and value for the payload.

After you send meter events, you can view usage details for your meter on the Meters page in the Dashboard.

  1. On the Meters page, select the meter name. For the Alpaca AI example, select Alpaca AI tokens.
  2. On the meter page, click Add usage > Manually input usage.
  3. On the Add usage page, do the following:
    • Select your customer from the Customer dropdown.
    • For Value, enter a sample value. For the Alpaca AI example, enter 3000.
    • Click Submit.

Create a preview invoice

Create a preview invoice to see a preview of a customer’s invoice that includes details such as the meter price and usage quantity.

  1. On the Subscriptions page, select a subscription. For the Alpaca AI example, select the subscription for John Doe.

  2. On the subscription details page, scroll down to the Upcoming invoice section. The preview invoice shows the subscription amount to bill the customer on the specified date.

  3. Click View full invoice to see complete details for the upcoming invoice, including:

    • Customer
    • Billing method
    • Creation date
    • Connected subscription
    • Subscription details (usage quantity and meter price)
    • Amount due

    Because Stripe processes meter events asynchronously, upcoming invoices might not immediately reflect recently received meter events.

OptionalRetrieve usage for a custom time period

Next steps

  • Accept payments with Stripe Checkout
  • Set up alerts and thresholds
  • Set up billing credits
Was this page helpful?
YesNo
Need help? Contact Support.
Join our early access program.
Check out our changelog.
Questions? Contact Sales.
LLM? Read llms.txt.
Powered by Markdoc
Related Guides
Usage-based pricing models
Products Used
Billing