Billing for AI: Using Autumn to Charge Per Token

By LatestLLM Editorial ·

Billing for AI: Using Autumn to Charge Per Token

Learn how to implement usage-based pricing for AI applications with Autumn, an open-source tool that enables per-token and per-request billing.

Key takeaways

  • Autumn is an open-source tool that enables usage-based billing for developers.
  • It supports granular metering, including per-token, per-request, and per-minute billing.
  • Usage-based models help AI developers protect margins against fluctuating API costs.
  • The tool serves as a more flexible and potentially cheaper alternative to platforms like Chargebee.
  • Developers can use pricing strategies like grandfathering to manage customer transitions.

You've spent weeks fine-tuning your LLM application, but there is a hidden leak in your bank account: every time a user sends a prompt, you pay for it.

If you use a flat monthly subscription, a single power user can easily cost you more in API fees than they pay in subscription dues.

Solving this requires a shift from traditional software billing to usage-based metering, and a new open-source tool called Autumn is making that transition accessible to everyone.

⚡ TL;DR: Autumn is an open-source billing tool available on GitHub that enables usage-based pricing for developers. It allows you to charge users per token, per request, or per minute, providing a flexible and cost-effective alternative to enterprise platforms like Chargebee.

The Simple Version

Most software follows the "Netflix Model." You pay a fixed monthly fee, whether you watch one movie or one hundred.

This works great for Spotify or Netflix because their marginal cost to serve you one more song is essentially zero. However, for AI developers, every single word generated by a model like GPT-4o has a literal, measurable cost.

If you charge a user $20 a month, but they use $50 worth of tokens, you are effectively paying for their hobby.

🎯 Think of it this way: Traditional SaaS is like a buffet where you pay one price and eat as much as you want. Usage-based billing is like a restaurant where you pay for every single appetizer, entree, and drink you order.

Autumn allows you to move your app from the "buffet" model to the "a la carte" model.

How It Works

The Power of Metering

To charge someone based on what they use, you need a way to count their usage in real-time. This process is called "metering."

As the video from The Next New Thing explains, Autumn doesn't just limit you to monthly subscriptions; it lets you meter almost anything your app needs.

You can set up your system to count every single API request, every minute of compute time, or even the specific number of tokens processed by an LLM.

Flexible Pricing Models

Once you are measuring usage, you can turn those measurements into money using different pricing structures.

You might decide to charge $0.01 per 1,000 tokens, or perhaps a flat $0.50 every time a user hits a "Generate" button.

This flexibility ensures that your revenue scales perfectly in proportion to your expenses, protecting your profit margins.

🎯 Think of it this way: It is like a utility company. You don't pay a flat fee for electricity; you have a meter on your house that tracks exactly how many kilowatt-hours you use each month.

Technical Deep Dive

The Architecture of Metered Billing

Implementing metered billing is significantly more complex than a simple Stripe subscription. In a standard subscription, you simply check if a user's `subscription_status` is `active` in your database.

With usage-based billing, you need an event-driven architecture to capture and aggregate usage data without slowing down your user experience.

For context, a typical implementation involves an event ingestion layer that receives a "usage event" every time an LLM call completes.

Tokenization and Event Emission

When working with LLMs, you aren't just counting characters; you are counting tokens. Tokens are the sub-word units that models like Llama 3 or Claude 3 use to process text.

To implement this, your backend must capture the `usage` object returned by the LLM provider (such as OpenAI's API), which typically includes `prompt_tokens` and `completion_tokens`.

This data is then emitted as a telemetry event to a billing engine like Autumn, which aggregates these counts over a billing cycle.

The Challenge of Idempotency and Latency

One major technical hurdle in metered billing is ensuring idempotency. If a network error occurs and your application retries an LLM request, you must ensure you don't charge the user twice for the same interaction.

Developers usually solve this by attaching a unique `idempotency_key` to every usage event sent to the billing service.

Furthermore, you must ensure that the billing logic does not add significant latency to the user's request. Most high-performance systems handle the billing event asynchronously, meaning the user gets their AI response immediately while the "counting" happens in the background.

Why This Matters

The era of "vibe coding"—rapidly building and deploying AI applications—has created a massive economic problem. Many developers are building incredible tools but aren't actually charging for them, or they are using broken pricing models that lead to losses.

The video points out that established players like Chargebee can be expensive. For example, the speaker notes that "Chargebee flow is about a hundred, actually it's a hundred about or exactly a hundred sixty bucks a month for a company that's billing twenty thousand dollars a month."

Beyond the cost, there is the risk of vendor lock-in. The video mentions that users often complain that "prices can double at renewal once you're locked in."

By using an open-source tool like Autumn from GitHub, developers gain more control over their stack and can implement smarter pricing strategies. For instance, you can use the "grandfathering" method mentioned in the video: raise prices for new customers while keeping older customers on their original, lower plans to maintain loyalty.

Ultimately, as AI agents and LLM-powered apps become more common, the ability to precisely match revenue to compute costs will be the difference between a successful startup and a bankrupt one.

Frequently asked questions

What is the difference between subscription billing and usage-based billing?

Subscription billing charges a fixed fee for access (like Netflix), while usage-based billing charges based on actual consumption (like a water meter).

Why is per-token billing important for AI apps?

LLM API costs vary depending on the length of the prompt and response; charging per token ensures your revenue scales with your actual compute costs.

Is Autumn free to use?

Yes, Autumn is described as free software that can be accessed directly via GitHub.

Sources

Source: “Billing for AI: Using Autumn to Charge Per Token” on YouTube by The Next New Thing

Tags: AI, SaaS, Billing, LLM, Open Source

Related articles