May 9, 2025

May 9, 2025

May 9, 2025

May 9, 2025

How to implement usage-based pricing using Flexprice

Building new features might be getting easier every day, but pricing them correctly is still a significant engineering challenge. Usage-based billing is one of the most powerful ways to align revenue with customer value, but it’s also one of the hardest to implement. It’s not just about counting API calls or storage bytes but it’s about building a real-time, scalable system that can handle millions of events per second. What starts as a simple project to track usage and bill customers can quickly turn into a never-ending engineering sprint.

But what if I told you that you could set up usage-based billing for your AI model within a weekend using Flexprice? Here’s how:

Step 1: Create a metered features

Features are the building blocks of your product offering. In Flexprice, you can use features to define what customers can do, how much they can use, and how they are charged like API endpoints, storage limits, premium dashboards, priority support, or advanced analytics.

Metered Features track quantifiable usage by customers, allowing you to bill them based on how much they use.



Flexprice allows you to define these features directly in the dashboard or via API, giving you full control over how each feature is measured and billed.

Step 2: Set-up a pricing plan

Once you have defined the metered features, the next step is to create a pricing plan. You can define a usage-only or hybrid plan as well. Flexprice support various kinds of billing models like flat fee, package, tiered volume etc.


For a typical OpenAI-like pricing model, you might use the following structure:

Metered Feature

Billing Model

Rate

Input Tokens

Package Charge

$15.00 per million tokens

Output Tokens

Package Charge

$60.00 per million tokens

Cached Tokens

Package Charge

$7.50 per million tokens

This means that if a customer uses 5 million input tokens, 2 million output tokens, and 1 million cached tokens, their invoice would be:

  • Input Tokens: 5M x $15.00 = $75.00

  • Output Tokens: 2M x $60.00 = $120.00

  • Cached Tokens: 1M x $7.50 = $7.50

  • Total Cost: $202.50


Step 3: Assign plan to customer and ingest events

Once your plan is ready, assign it to a customer. This can be done via the Flexprice dashboard or through the API, allowing for automated onboarding.


As soon as customers start using your platform, you can send events on real-time to Flexprice via APIs. You can even directly try to link your data-sources like PostHog, Snowflake or more. Our platform will:

  • Aggregate these events.

  • Calculate real-time usage.

  • Automatically generate accurate invoices based on the defined plan.


AI companies often deal with highly variable costs, like GPU usage, model inference times, and API calls and what if your pricing strategy changes tomorrow? Maybe today you’re billing for tokens, but as your models become more sophisticated, you might want to switch to GPU time, API latency, or even feature-specific usage. With Flexprice, you’re not locked into a single pricing model. You can add new metered features, adjust rates, or experiment with hybrid pricing models without overhauling your entire billing stack.

This is the power of Flexprice—flexibility without complexity. It’s open source, developer-friendly, and built to scale with you as your AI business grows.

Ready to take control of your pricing?
Try Flexprice today. It’s open source, free to use, and built for builders like you.

Blogs

Blogs

Blogs

More insights on billing

Insights on
billing and beyond

Explore expert tips, industry trends, and best practices for billing, pricing, and scaling revenue.

Get started with your billing today

Get started with
your billing today