Flexprice
Open-source usage metering, credits and invoicing for products where the cost of serving a customer is real — self-hostable, and built to sit alongside your payment processor rather than replace it
Flexprice is an open-source billing layer for usage-based, credit-based and hybrid pricing, written in Go and licensed AGPL-3.0 with a smaller commercially-licensed enterprise portion. It meters usage events in real time, applies prepaid or promotional credits, enforces per-plan feature limits, and generates invoices from what was actually consumed. It is designed to sit on top of a payment processor rather than take its place, which makes it a metering and pricing-logic layer rather than a checkout.
What Flexprice is
Flexprice (github.com/flexprice/flexprice) is a Go service you can self-host or use as the maintainers' hosted product. Your application sends usage events through the Go, Python or JavaScript SDKs — or you stream them from a warehouse or analytics pipeline — and Flexprice does the aggregation, applies the customer's pricing rules and credits, and produces the invoice. The repo has been in development since November 2024 and is released under AGPL-3.0, copyright a private company that also sells the hosted version.
The pitch the project makes for itself is that billing quietly became a developer problem: subscription tools handle simple plans well and everything past that — metering, credit balances, feature gating, custom invoice logic — becomes application code somebody has to maintain forever. The documented feature set follows from that. Usage metering at event granularity, credit grants covering prepaid and promotional balances with automatic top-ups at thresholds and expiry rules, pricing plans spanning seat-based, pay-as-you-go, volume-tiered and hybrid shapes with per-customer overrides and plan versioning, feature entitlements with usage limits, and invoicing that handles proration and overages. It connects outward to payment, CRM and accounting tools rather than owning any of them.
What you have to record before you can charge for it
Every pricing shape implies a measurement, and the measurement is the part founders skip. It is worth being concrete about what each shape actually demands of your data, because the cost of getting it wrong is not a bad invoice — it is a month you cannot reconstruct.
| Pricing shape | What the meter has to record | What breaks without it |
|---|---|---|
| Flat subscription | Who is on which plan, and when they moved | Very little. This is the one shape that survives with almost no measurement |
| Per-seat | Seat count over time, not just the count today | Mid-cycle seat changes invoice wrong, and the disputes cost more staff time than the revenue |
| Pay-as-you-go | Every billable event, attributed to a customer, stamped with when it happened | You cannot answer "why is my bill this size", and you cannot re-run a month after fixing a bug |
| Prepaid credits | A balance per customer plus every debit and the reason for it | Balances drift from reality, and support has to take the customer's word for what was spent |
| Allowance then overage | The allowance consumed and the overage as separate numbers | The boundary is invisible, so nobody can be warned before they cross it and every crossing is a surprise |
Read down the middle column and the argument for looking at a tool like this early becomes clearer. The reason is not that invoicing is hard — it is that the meter is the one part you cannot add retroactively. Pricing can be changed next quarter. The events of last quarter either exist or they do not.
Licence and hosting, before you deploy
The repo's LICENSE file is AGPL-3.0, and the README describes an open-core split: the core is AGPLv3, and a smaller enterprise portion under the ee and internal/ee directories carries a separate commercial licence. Those directories do exist in the tree, so if your plan depends on a specific capability it is worth checking which side of the line it sits on before you build against it. For running the thing yourself to bill your own customers, AGPL is unremarkable. The clause worth understanding is the network one, which reaches people who use the software over a network without ever downloading it, so offering a modified Flexprice as a service to others is the case to put in front of a lawyer rather than reason about yourself.
Operationally it is not one small container. The repo's own topics name PostgreSQL, ClickHouse, Kafka and Temporal, and local setup runs as a compose stack — proportionate for something that has to aggregate high-volume events reliably, and disproportionate for a product with forty customers on a flat plan. It is also actively developed rather than finished: v2.1.23 was released on 2026-08-05 and functional commits were still landing on 2026-08-14, including invoicing and CRM integration work. That is a good sign for the project and a real commitment for you, because a self-hosted billing system is something you keep upgrading, not something you deploy once.
Build the meter before you need it
We meter per-customer model spend on our own platform, and the thing worth passing on is how quietly a meter fails. Ours had three separate faults in its first weeks and not one of them raised an error. The collector read a cache the runtime only refreshed when explicitly asked, so the ledger was simply empty. Once that was fixed it harvested only the main agent's usage, so every specialist's spend recorded as zero — which under-counted exactly the heaviest accounts, the ones where the number mattered most. And because rows were keyed by day and model alone, a restarted container's partial view could overwrite the stored total, once rolling a single row backwards by tens of thousands of tokens.
The pattern is the lesson. Every one of those faults produced a smaller number, and a smaller number looks like good news, so nothing prompted anyone to check. A meter needs a test that fails when it under-reports, not only when it errors. The fix in our case was making a row's identity include the session that produced it, so a partial view can no longer overwrite a complete one. If you are pricing a product whose cost per customer is real — which is most AI products — the ordering is the same whether you adopt Flexprice or write twenty lines of your own: meter first, then price. A price set too high can be lowered next month. A quarter you never measured cannot be recovered, and you will not be able to say which customers were expensive.
FAQ
- Is Flexprice a replacement for Stripe?
- No, and the project does not present it as one. It describes itself as composable — a metering, credits and pricing-logic layer that sits on top of an existing payment provider and pushes the resulting invoices and revenue data out to the systems you already run. You still need a processor to take money and a way to handle cards and disputes. What moves is the part that decides how much to charge.
- Is Flexprice free?
- The repository is AGPL-3.0 and self-hostable, so you can run it without paying for a licence. Two caveats are worth reading directly rather than taking on trust: the README describes an open-core split with a smaller enterprise portion under a commercial licence in the ee and internal/ee directories, and the maintainers also sell a hosted version. Self-hosting is free of licence fees and not free of infrastructure and upgrade work.
- Do I need a billing system like this at the start?
- Probably not the service. You almost certainly do need the event log it is built around. The cheapest useful version is one append-only table recording who did what, when, and how much it cost you — written from day one, before there is any pricing question to answer. Adopting a metering platform later is a normal migration. Reconstructing usage you never recorded is not possible at all.
- What does the AGPL licence mean for my SaaS?
- Running Flexprice on your own infrastructure to bill your own customers is the ordinary case and is unremarkable. The clause that makes AGPL different from GPL is the network one: it extends the obligation to publish your modifications to users who reach the software over a network rather than only to people who receive a copy. If you plan to modify it and offer it to others as part of a service, that is a question for a lawyer. This is a description of the licence, not legal advice.
- What does self-hosting Flexprice actually cost to run?
- More than a single container. The project's own topics list PostgreSQL, ClickHouse, Kafka and Temporal, and the repo ships a compose file for local development, so the realistic shape is a managed database plus a couple of stateful services. Add frequent releases — the repo was shipping functional commits in mid-August 2026 — which means an ongoing upgrade habit for a system you cannot afford to have drift.
You built it. Now grow it.
AgentCeres is a managed AI marketing team — specialists draft the SEO, social, and outreach that fill your links, you approve what ships. 14-day free trial, from $39/month.