A custom metering layer gets scoped as four or five database tables and a handful of aggregation queries. Then the product needs usage dashboards customers can open themselves. Then come mid-cycle usage alerts. Then billing disputes demand event-level audit logs retained for months. Then the pricing model shifts and aggregation has to be updated without invalidating invoices already issued. The estimate from week one covers only a fraction of the work. Most of it arrives across the first eighteen months in production, in pieces nobody scoped at the start.
The build-or-buy question applies here, with one difference from the usual infrastructure analysis. Billing cannot be skipped, its tolerance for error is lower than most internal tools, and its complexity tracks the pricing model rather than how much effort the team puts in.
The Parts You Sign Up For
Usage billing for an agentic product needs several pieces, each substantial on its own:
- An event ingestion API built for high write throughput and safe retries
- Deduplication with a configurable window and a managed key store
- A pricing rules engine mapping event types to rates, including tiered and volume pricing
- Live aggregation that keeps a running total per customer per billing period
- Invoice generation whose line items trace back to event records
- Customer-facing usage dashboards queryable across time ranges and event dimensions
- Webhook delivery for billing events: threshold alerts, invoice issued, payment due
- A tamper-resistant audit log that can be queried during a dispute
Every one of those has a straightforward first implementation and an edge-case surface that is anything but. Idempotency is a known pattern; a key store that carries 10 million events a day without becoming a throughput bottleneck is an engineering project. Live aggregation sounds simple; clock skew across event sources producing wrong running totals is the hard part. Correct line items are manageable; applying a changed pricing rule retroactively to a partially closed period is a data migration.
What Maintenance Looks Like a Year In
Billing systems seldom get rewritten outright. They get extended, and extending billing code carries more risk than extending most product code because a mistake reaches customers directly. Adding an event type to the pricing model means touching schema, pricing rules, aggregation, invoice template, dashboards, and then testing retroactive correctness. In a small team's incrementally grown system, those pieces live in different places, and the change needs someone who holds the whole data model in their head.
The opportunity cost is concrete: every engineering hour spent maintaining billing is an hour not spent on whatever makes the product distinct. For an early-stage AI team, billing sits underneath the product rather than inside it. Building it in-house makes sense when the billing requirements themselves are differentiated. When they are standard, it pulls attention away from the actual work.
Cases Where Custom Makes Sense
Some situations do call for custom infrastructure. A genuinely novel pricing model—rules that depend on external signals in real time, or contract terms negotiated one customer at a time—may exceed what off-the-shelf systems support. A regulatory regime that keeps billing data inside a geographic boundary or under governance terms no SaaS vendor can satisfy makes building a compliance obligation rather than a preference.
Latency that requires co-location with the event source, beyond what a well-placed API endpoint can deliver, can make building the only viable architecture. These scenarios exist. They are not the typical case.
The Case for Renting the Layer
Most AI product teams need event metering, idempotent ingestion, pricing rules, and invoice generation. All four are solved problems. People who can build them correctly are not scarce in principle, but developing and applying that skill takes time, and the product engineering that does not happen during that time is a real loss.
The less obvious argument for buying is battle-testing. Infrastructure that has run against heavy event volumes for many customers under many pricing configurations has met edge cases a first-version system has not: key collision patterns, clock skew, pricing retroactivity, invoice correction flows. Those problems surface in production, not in design, and a provider pays the discovery cost once, while every team building their own pays it again.
How to Decide
The question is not whether you can build it. You can. The question is whether your pricing model demands capabilities off-the-shelf infrastructure lacks, or whether the engineering hours spent building and maintaining billing would do more for the product itself.
Put the model in one sentence: event types mapped to rates, with optional tiers and volume discounts, applied per customer over a billing period. If that covers your case, you have a configuration problem, not a custom-infrastructure problem. Solving it in a system built for that configuration is quicker, more reliable at the edges, and leaves engineering free for the work that differentiates you.
Paygentic exists because the same eight-part system kept getting rebuilt by AI teams who underestimated the scope, then spent a year keeping it alive. Every build-or-buy calculation for infrastructure reads differently once the full scope of the commitment is on the table.