# Model usage-based pricing Learn about the different pricing models for usage-based billing on Stripe. Common pricing models include fixed fee and overage, pay as you go, or credit burndown. Use the guidance below to set up these pricing models in Stripe. ## Fixed fee and overage model Use the fixed fee and overage model to charge a flat fee per month for your service at the beginning of the period. The flat fee has some included usage entitlement, and any additional usage (overage) charges at the end of the period. You can use the Stripe Dashboard or API to set this up with two prices within the same product. For example, Alpaca AI introduces an advanced model called Llama AI. Priced at 200 USD per month, this model includes 100,000 tokens. We charge any usage above the included tokens at an additional rate of 0.001 USD per token. 1. On the [Product catalog](https://dashboard.stripe.com/test/products) page, click **Create product**. 1. On the **Add a product** page, do the following: - For **Name**, enter the name of your product. For the Alpaca AI example, enter `Llama AI`. - (Optional) For **Description**, add a description that appears at checkout in the [customer portal](https://docs.stripe.com/customer-management.md) and in [quotes](https://docs.stripe.com/quotes.md). - Under **Billing period**, select **More pricing options**. 1. On the **Add price** page, do the following: - Under **Choose your pricing model**, select **Flat rate**. - Under **Price**, set the **Amount** to `200.00 USD`. - Click **Next** 1. To add a second recurring price to the product, click **Add another price** on the **Add a product** page. 1. On the **Add price** page,do the following: - Under **Choose your pricing model**, select **Usage-based**, **Per tier**, and **Graduated**. - Under **Price**, create two graduated pricing tiers: | | First unit | Last unit | Per unit | Flat fee | | ------------- | ---------- | --------- | --------- | -------- | | For the first | 0 | 100,000 | 0.00 USD | 0.00 USD | | For the next | 100,001 | ∞ | 0.001 USD | 0.00 USD | 1. Under **Meter**, create a new meter to record usage. For the Alpaca AI example, use the meter name `llama_api_tokens`. 1. Click **Next**. 1. Click **Add product**. When you create subscriptions, specify both prices. First, create your [product](https://docs.stripe.com/api/products.md). For the Alpaca AI example, use the name `Alpaca AI tokens`. ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new ProductCreateOptions { Name = "Alpaca AI tokens" }; var service = new ProductService(); Product product = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.ProductParams{Name: stripe.String("Alpaca AI tokens")}; result, err := product.New(params); ``` ```java Stripe.apiKey = "<>"; ProductCreateParams params = ProductCreateParams.builder().setName("Alpaca AI tokens").build(); Product product = Product.create(params); ``` ```node const stripe = require('stripe')('<>'); const product = await stripe.products.create({ name: 'Alpaca AI tokens', }); ``` ```python import stripe stripe.api_key = "<>" product = stripe.Product.create(name="Alpaca AI tokens") ``` ```php $stripe = new \Stripe\StripeClient('<>'); $product = $stripe->products->create(['name' => 'Alpaca AI tokens']); ``` ```ruby Stripe.api_key = '<>' product = Stripe::Product.create({name: 'Alpaca AI tokens'}) ``` Next, add a flat fee [price](https://docs.stripe.com/api/prices.md) to the product with a licensed rate of 200 USD. ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new PriceCreateOptions { Product = "{{PRODUCT_ID}}", Currency = "usd", UnitAmount = 20000, BillingScheme = "per_unit", Recurring = new PriceRecurringOptions { UsageType = "licensed", Interval = "month" }, }; var service = new PriceService(); Price price = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.PriceParams{ Product: stripe.String("{{PRODUCT_ID}}"), Currency: stripe.String(string(stripe.CurrencyUSD)), UnitAmount: stripe.Int64(20000), BillingScheme: stripe.String(string(stripe.PriceBillingSchemePerUnit)), Recurring: &stripe.PriceRecurringParams{ UsageType: stripe.String(string(stripe.PriceRecurringUsageTypeLicensed)), Interval: stripe.String(string(stripe.PriceRecurringIntervalMonth)), }, }; result, err := price.New(params); ``` ```java Stripe.apiKey = "<>"; PriceCreateParams params = PriceCreateParams.builder() .setProduct("{{PRODUCT_ID}}") .setCurrency("usd") .setUnitAmount(20000L) .setBillingScheme(PriceCreateParams.BillingScheme.PER_UNIT) .setRecurring( PriceCreateParams.Recurring.builder() .setUsageType(PriceCreateParams.Recurring.UsageType.LICENSED) .setInterval(PriceCreateParams.Recurring.Interval.MONTH) .build() ) .build(); Price price = Price.create(params); ``` ```node const stripe = require('stripe')('<>'); const price = await stripe.prices.create({ product: '{{PRODUCT_ID}}', currency: 'usd', unit_amount: 20000, billing_scheme: 'per_unit', recurring: { usage_type: 'licensed', interval: 'month', }, }); ``` ```python import stripe stripe.api_key = "<>" price = stripe.Price.create( product="{{PRODUCT_ID}}", currency="usd", unit_amount=20000, billing_scheme="per_unit", recurring={"usage_type": "licensed", "interval": "month"}, ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $price = $stripe->prices->create([ 'product' => '{{PRODUCT_ID}}', 'currency' => 'usd', 'unit_amount' => 20000, 'billing_scheme' => 'per_unit', 'recurring' => [ 'usage_type' => 'licensed', 'interval' => 'month', ], ]); ``` ```ruby Stripe.api_key = '<>' price = Stripe::Price.create({ product: '{{PRODUCT_ID}}', currency: 'usd', unit_amount: 20000, billing_scheme: 'per_unit', recurring: { usage_type: 'licensed', interval: 'month', }, }) ``` Then, add a metered price to the product with a graduated rate with two tiers. For the first tier, specify 0 to 100,000 units at 200 USD. For the second tier, specify 0.001 USD per unit. The first tier has a price of 0 USD because the flat rate includes the first 100,000 units. Finally, specify both price IDs when you [create a subscription](https://docs.stripe.com/billing/subscriptions/usage-based/implementation-guide.md#create-subscription). ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new SubscriptionCreateOptions { Customer = "{{CUSTOMER_ID}}", Items = new List { new SubscriptionItemOptions { Price = "{{FLAT_MONTHLY_FEE_PRICE_ID}}", Quantity = 1 }, new SubscriptionItemOptions { Price = "{{METERED_USAGE_PRICE_ID}}" }, }, }; var service = new SubscriptionService(); Subscription subscription = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.SubscriptionParams{ Customer: stripe.String("{{CUSTOMER_ID}}"), Items: []*stripe.SubscriptionItemsParams{ &stripe.SubscriptionItemsParams{ Price: stripe.String("{{FLAT_MONTHLY_FEE_PRICE_ID}}"), Quantity: stripe.Int64(1), }, &stripe.SubscriptionItemsParams{Price: stripe.String("{{METERED_USAGE_PRICE_ID}}")}, }, }; result, err := subscription.New(params); ``` ```java Stripe.apiKey = "<>"; SubscriptionCreateParams params = SubscriptionCreateParams.builder() .setCustomer("{{CUSTOMER_ID}}") .addItem( SubscriptionCreateParams.Item.builder() .setPrice("{{FLAT_MONTHLY_FEE_PRICE_ID}}") .setQuantity(1L) .build() ) .addItem(SubscriptionCreateParams.Item.builder().setPrice("{{METERED_USAGE_PRICE_ID}}").build()) .build(); Subscription subscription = Subscription.create(params); ``` ```node const stripe = require('stripe')('<>'); const subscription = await stripe.subscriptions.create({ customer: '{{CUSTOMER_ID}}', items: [ { price: '{{FLAT_MONTHLY_FEE_PRICE_ID}}', quantity: 1, }, { price: '{{METERED_USAGE_PRICE_ID}}', }, ], }); ``` ```python import stripe stripe.api_key = "<>" subscription = stripe.Subscription.create( customer="{{CUSTOMER_ID}}", items=[ {"price": "{{FLAT_MONTHLY_FEE_PRICE_ID}}", "quantity": 1}, {"price": "{{METERED_USAGE_PRICE_ID}}"}, ], ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $subscription = $stripe->subscriptions->create([ 'customer' => '{{CUSTOMER_ID}}', 'items' => [ [ 'price' => '{{FLAT_MONTHLY_FEE_PRICE_ID}}', 'quantity' => 1, ], ['price' => '{{METERED_USAGE_PRICE_ID}}'], ], ]); ``` ```ruby Stripe.api_key = '<>' subscription = Stripe::Subscription.create({ customer: '{{CUSTOMER_ID}}', items: [ { price: '{{FLAT_MONTHLY_FEE_PRICE_ID}}', quantity: 1, }, {price: '{{METERED_USAGE_PRICE_ID}}'}, ], }) ``` ## Pay as you go The pay as you go model (also called in arrears billing) lets you track usage incurred over a determined period, then charge the customer at the end of the period. You can use rate cards to set up the pay as you go model. Rate cards are currently in [private preview](https://docs.stripe.com/release-phases.md). Reach out to request access. You can deploy any of the following pricing strategies: - **Per unit**: Charge the same amount for each unit. - **Per package**: Charge an amount for a package or bundle of units or usage. - **Tiered and volume-based pricing**: With [volume pricing](https://docs.stripe.com/products-prices/pricing-models.md#volume-based-pricing), you charge the subscription item at the tier that corresponds to the usage amount at the end of the period. - **Tiered and graduated pricing**: Similar to volume pricing, [graduated pricing](https://docs.stripe.com/products-prices/pricing-models.md#graduated-pricing) charges for the usage in each tier instead of applying a single price to all usage. This model might cause customers to accumulate significant usage, and affect their payment method status at the end of the month. ## Credit burndown The credit burndown model lets you collect prepayment for usage-based products and services. Customers can use [billing credits](https://docs.stripe.com/billing/subscriptions/usage-based/billing-credits.md) to pay an initial amount, and then apply their billing credits as they use the product. You can use rate cards to set up the pay as you go model. Rate cards are currently in [private preview](https://docs.stripe.com/release-phases.md). Reach out to request access. For example, Alpaca AI wants to sell a large enterprise contract to an existing self-serve customer for their new Llama AI Model. The customer commits to pay 100,000 USD up front for Llama AI, so they can get 120,000 USD of billing credit usage to use within 1 year. ### Collect prepayment from a customer 1. On the [Invoices](https://dashboard.stripe.com/invoices) page, click **Create invoice**. 1. Select your customer from the **Customer** dropdown. 1. Select **USD - US Dollar** from the **Currency** dropdown. 1. Under **Items**, select **Add a new line item**. 1. Under **Item details**, do the following: - For **Item**, enter `Llama AI Credits`. - For **Price**, enter `100,000`. - Click **Save**. 1. Click **Send invoice**. After your customer pays the invoice, you can grant them billing credits. ### Grant billing credits to a customer 1. On the [Customers](https://dashboard.stripe.com/test/customers) page, select the customer name. 1. On the customer page, under **Credit grants**, click the plus (**+**) symbol. 1. On the **New credit grant** page, do the following: - For **Name**, enter a name for your credit grant. - For **Amount**, specify the amount of the credit grant. For the Alpaca AI example, enter `120,000`. - Under **Expiry date**, specify the date, if any, when the credits expire. For the Alpaca AI example, select **Specific date** and set a date 12 months from now. - Click **Create grant**. First, create an invoice. ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new InvoiceCreateOptions { Description = "Alpaca AI Credits", Customer = "{{CUSTOMER_ID}}", CollectionMethod = "charge_automatically", }; var service = new InvoiceService(); Invoice invoice = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.InvoiceParams{ Description: stripe.String("Alpaca AI Credits"), Customer: stripe.String("{{CUSTOMER_ID}}"), CollectionMethod: stripe.String(string(stripe.InvoiceCollectionMethodChargeAutomatically)), }; result, err := invoice.New(params); ``` ```java Stripe.apiKey = "<>"; InvoiceCreateParams params = InvoiceCreateParams.builder() .setDescription("Alpaca AI Credits") .setCustomer("{{CUSTOMER_ID}}") .setCollectionMethod(InvoiceCreateParams.CollectionMethod.CHARGE_AUTOMATICALLY) .build(); Invoice invoice = Invoice.create(params); ``` ```node const stripe = require('stripe')('<>'); const invoice = await stripe.invoices.create({ description: 'Alpaca AI Credits', customer: '{{CUSTOMER_ID}}', collection_method: 'charge_automatically', }); ``` ```python import stripe stripe.api_key = "<>" invoice = stripe.Invoice.create( description="Alpaca AI Credits", customer="{{CUSTOMER_ID}}", collection_method="charge_automatically", ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $invoice = $stripe->invoices->create([ 'description' => 'Alpaca AI Credits', 'customer' => '{{CUSTOMER_ID}}', 'collection_method' => 'charge_automatically', ]); ``` ```ruby Stripe.api_key = '<>' invoice = Stripe::Invoice.create({ description: 'Alpaca AI Credits', customer: '{{CUSTOMER_ID}}', collection_method: 'charge_automatically', }) ``` Next, add the billing credits to the invoice. ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new InvoiceItemCreateOptions { Customer = "{{CUSTOMER_ID}}", Currency = "usd", UnitAmountDecimal = 10000000M, }; var service = new InvoiceItemService(); InvoiceItem invoiceItem = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.InvoiceItemParams{ Customer: stripe.String("{{CUSTOMER_ID}}"), Currency: stripe.String(string(stripe.CurrencyUSD)), UnitAmountDecimal: stripe.Float64(10000000), }; result, err := invoiceitem.New(params); ``` ```java Stripe.apiKey = "<>"; InvoiceItemCreateParams params = InvoiceItemCreateParams.builder() .setCustomer("{{CUSTOMER_ID}}") .setCurrency("usd") .setUnitAmountDecimal(new BigDecimal("10000000")) .build(); InvoiceItem invoiceItem = InvoiceItem.create(params); ``` ```node const stripe = require('stripe')('<>'); const invoiceItem = await stripe.invoiceItems.create({ customer: '{{CUSTOMER_ID}}', currency: 'usd', unit_amount_decimal: '10000000', }); ``` ```python import stripe stripe.api_key = "<>" invoice_item = stripe.InvoiceItem.create( customer="{{CUSTOMER_ID}}", currency="usd", unit_amount_decimal="10000000", ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $invoiceItem = $stripe->invoiceItems->create([ 'customer' => '{{CUSTOMER_ID}}', 'currency' => 'usd', 'unit_amount_decimal' => '10000000', ]); ``` ```ruby Stripe.api_key = '<>' invoice_item = Stripe::InvoiceItem.create({ customer: '{{CUSTOMER_ID}}', currency: 'usd', unit_amount_decimal: '10000000', }) ``` Then, finalize the invoice. ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new InvoiceFinalizeOptions { AutoAdvance = true }; var service = new InvoiceService(); Invoice invoice = service.FinalizeInvoice("{{INVOICE_ID}}", options); ``` ```go stripe.Key = "<>" params := &stripe.InvoiceFinalizeInvoiceParams{AutoAdvance: stripe.Bool(true)}; result, err := invoice.FinalizeInvoice("{{INVOICE_ID}}", params); ``` ```java Stripe.apiKey = "<>"; Invoice resource = Invoice.retrieve("{{INVOICE_ID}}"); InvoiceFinalizeInvoiceParams params = InvoiceFinalizeInvoiceParams.builder().setAutoAdvance(true).build(); Invoice invoice = resource.finalizeInvoice(params); ``` ```node const stripe = require('stripe')('<>'); const invoice = await stripe.invoices.finalizeInvoice( '{{INVOICE_ID}}', { auto_advance: true, } ); ``` ```python import stripe stripe.api_key = "<>" invoice = stripe.Invoice.finalize_invoice( "{{INVOICE_ID}}", auto_advance=True, ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $invoice = $stripe->invoices->finalizeInvoice('{{INVOICE_ID}}', ['auto_advance' => true]); ``` ```ruby Stripe.api_key = '<>' invoice = Stripe::Invoice.finalize_invoice('{{INVOICE_ID}}', {auto_advance: true}) ``` After your customer pays the invoice, you can grant them billing credits. ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Billing.CreditGrantCreateOptions { Customer = "{{CUSTOMER_ID}}", Category = "paid", Amount = new Stripe.Billing.CreditGrantAmountOptions { Type = "monetary", Monetary = new Stripe.Billing.CreditGrantAmountMonetaryOptions { Value = 12000000, Currency = "usd", }, }, ApplicabilityConfig = new Stripe.Billing.CreditGrantApplicabilityConfigOptions { Scope = new Stripe.Billing.CreditGrantApplicabilityConfigScopeOptions { PriceType = "metered", }, }, ExpiresAt = DateTimeOffset.FromUnixTimeSeconds(1759341179).UtcDateTime, }; var service = new Stripe.Billing.CreditGrantService(); Stripe.Billing.CreditGrant creditGrant = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.BillingCreditGrantParams{ Customer: stripe.String("{{CUSTOMER_ID}}"), Category: stripe.String(string(stripe.BillingCreditGrantCategoryPaid)), Amount: &stripe.BillingCreditGrantAmountParams{ Type: stripe.String("monetary"), Monetary: &stripe.BillingCreditGrantAmountMonetaryParams{ Value: stripe.Int64(12000000), Currency: stripe.String(string(stripe.CurrencyUSD)), }, }, ApplicabilityConfig: &stripe.BillingCreditGrantApplicabilityConfigParams{ Scope: &stripe.BillingCreditGrantApplicabilityConfigScopeParams{ PriceType: stripe.String("metered"), }, }, ExpiresAt: stripe.Int64(1759341179), }; result, err := creditgrant.New(params); ``` ```java Stripe.apiKey = "<>"; CreditGrantCreateParams params = CreditGrantCreateParams.builder() .setCustomer("{{CUSTOMER_ID}}") .setCategory(CreditGrantCreateParams.Category.PAID) .setAmount( CreditGrantCreateParams.Amount.builder() .setType(CreditGrantCreateParams.Amount.Type.MONETARY) .setMonetary( CreditGrantCreateParams.Amount.Monetary.builder() .setValue(12000000L) .setCurrency("usd") .build() ) .build() ) .setApplicabilityConfig( CreditGrantCreateParams.ApplicabilityConfig.builder() .setScope( CreditGrantCreateParams.ApplicabilityConfig.Scope.builder() .setPriceType(CreditGrantCreateParams.ApplicabilityConfig.Scope.PriceType.METERED) .build() ) .build() ) .setExpiresAt(1759341179L) .build(); CreditGrant creditGrant = CreditGrant.create(params); ``` ```node const stripe = require('stripe')('<>'); const creditGrant = await stripe.billing.creditGrants.create({ customer: '{{CUSTOMER_ID}}', category: 'paid', amount: { type: 'monetary', monetary: { value: 12000000, currency: 'usd', }, }, applicability_config: { scope: { price_type: 'metered', }, }, expires_at: 1759341179, }); ``` ```python import stripe stripe.api_key = "<>" credit_grant = stripe.billing.CreditGrant.create( customer="{{CUSTOMER_ID}}", category="paid", amount={"type": "monetary", "monetary": {"value": 12000000, "currency": "usd"}}, applicability_config={"scope": {"price_type": "metered"}}, expires_at=1759341179, ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $creditGrant = $stripe->billing->creditGrants->create([ 'customer' => '{{CUSTOMER_ID}}', 'category' => 'paid', 'amount' => [ 'type' => 'monetary', 'monetary' => [ 'value' => 12000000, 'currency' => 'usd', ], ], 'applicability_config' => ['scope' => ['price_type' => 'metered']], 'expires_at' => 1759341179, ]); ``` ```ruby Stripe.api_key = '<>' credit_grant = Stripe::Billing::CreditGrant.create({ customer: '{{CUSTOMER_ID}}', category: 'paid', amount: { type: 'monetary', monetary: { value: 12000000, currency: 'usd', }, }, applicability_config: {scope: {price_type: 'metered'}}, expires_at: 1759341179, }) ``` ## Free trials You can use [trial periods for subscriptions](https://docs.stripe.com/billing/subscriptions/trials.md) with usage-based billing. During the trial period, any usage accrued doesn’t count toward the total charged to the customer at the end of the billing cycle. After the trial period ends, the usage accrues and bills at the end of the next billing cycle. Make sure your integration properly monitors and handles [webhook events](https://docs.stripe.com/billing/subscriptions/webhooks.md) related to trial status changes. A few days before a trial ends and the subscription moves from `trialing` to `active`, you receive a `customer.subscription.trial_will_end` event. When you receive this event, make sure you have a payment method on the customer account to bill them. Optionally, provide advance notification to the customer about the upcoming charge. | Status | Description | | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `trialing` | The subscription is currently in a trial period and you can safely provision your product for your customer. The subscription transitions automatically to `active` when a customer makes the first payment. | | `active` | The subscription is in good standing. For `past_due` subscriptions, paying the latest associated invoice or marking it uncollectible transitions the subscription to `active`. Note that `active` doesn’t indicate that all outstanding invoices associated with the subscription have been paid. You can leave other outstanding invoices open for payment, mark them as uncollectible, or void them as you see fit. | | `incomplete` | The customer must make a successful payment within 23 hours to activate the subscription. Or the payment [requires action](#requires-action), such as customer authentication. Subscriptions can also be `incomplete` if there’s a pending payment and the PaymentIntent status is `processing`. | | `incomplete_expired` | The initial payment on the subscription failed and the customer didn’t make a successful payment within 23 hours of subscription creation. These subscriptions don’t bill customers. This status exists so you can track customers that failed to activate their subscriptions. | | `past_due` | Payment on the latest _finalized_ invoice either failed or wasn’t attempted. The subscription continues to create invoices. Your [subscription settings](https://docs.stripe.com/billing/subscriptions/overview.md#settings) determine the subscription’s next state. If the invoice is still unpaid after all attempted [smart retries](https://docs.stripe.com/billing/revenue-recovery/smart-retries.md), you can configure the subscription to move to `canceled`, `unpaid`, or leave it as `past_due`. To move the subscription to `active`, pay the most recent invoice before its due date. | | `canceled` | The subscription was canceled. During cancellation, automatic collection for all unpaid invoices is disabled (`auto_advance=false`). This is a terminal state that can’t be updated. | | `unpaid` | The latest invoice hasn’t been paid but the subscription remains in place. The latest invoice remains open and invoices continue to generate, but payments aren’t attempted. Revoke access to your product when the subscription is `unpaid` because payments were already attempted and retried while `past_due`. To move the subscription to `active`, pay the most recent invoice before its due date. | | `paused` | The subscription has ended its trial period without a default payment method and the [trial_settings.end_behavior.missing_payment_method](https://docs.stripe.com/billing/subscriptions/trials.md#create-free-trials-without-payment) is set to `pause`. Invoices are no longer created for the subscription. After attaching a default payment method to the customer, you can [resume the subscription](https://docs.stripe.com/billing/subscriptions/trials.md#resume-a-paused-subscription). | Learn more about [subscriptions and webhooks](https://docs.stripe.com/billing/subscriptions/webhooks.md).