A multi-tenant AI platform was scaling into enterprise contracts and hit a structural wall: the pricing model could not be expressed by any off-the-shelf billing tool. Enterprise customers needed per-unit processing fees with multiple pricing dimensions, per-site minimum commitments, annual spending caps, and role-based finance access with auditable invoices. Standard billing tools handle subscriptions and simple metering. They do not handle the interactions between multiple pricing dimensions that enterprise contracts require.
ML LABS designed and built the complete billing system — from deployment infrastructure through invoice PDF generation — a full billing portal deployed across three environments with self-service access for finance teams.
The Problem
The platform processed thousands of units daily across dozens of sites. Enterprise contracts specified multiple pricing dimensions — per-unit rates by processing category, per-site monthly minimums, and annual spending caps — with complex interactions between them. None of these rules exist in isolation; they interact at invoice time in ways that produce incorrect totals if any single rule is applied without awareness of the others.
Deployment and Access Infrastructure
ML LABS stood up the full deployment pipeline across three environments — test, US production, and UK production — with environment-specific configuration and tenant isolation.
Authentication provided finance teams with self-service access to invoices and dashboards without exposing operational platform features. MFA enforcement ensured billing data access met the security posture required for financial records in a regulated environment.
Metering and Pricing Engine
Every processing event generated a billing event tagged with site, category, and timestamp. The metering layer captured, classified, and aggregated these events by billing period and site.
The pricing engine enforced all contractual rules — per-unit rates, site-level minimums, and annual caps — with correct handling of interactions between them. Each rule interaction has a specific failure mode that produces invoices finance teams will dispute.
graph TD
A1["Processing Events"] --> A2["Classification<br/>and Aggregation"]
A2 --> A3["Per-Unit<br/>Rating"]
A3 --> A4["Minimum and Cap<br/>Enforcement"]
A4 --> A5["Verified<br/>Invoice Totals"]
style A1 fill:#1a1a2e,stroke:#0f3460,color:#fff
style A2 fill:#1a1a2e,stroke:#0f3460,color:#fff
style A3 fill:#1a1a2e,stroke:#ffd700,color:#fff
style A4 fill:#1a1a2e,stroke:#16c79a,color:#fff
style A5 fill:#1a1a2e,stroke:#16c79a,color:#fffInvoice Generation
The invoice PDF had to serve as both a billing document and a reconciliation tool. ML LABS built the invoice generator to produce structured documents with summary totals, per-site breakdowns with line-item transparency, and verification totals that prove the breakdown sums correctly. For organizations with dozens of sites, this meant multi-page invoices with consistent formatting throughout.
Dashboard-Invoice Reconciliation
The billing dashboard showed current-period charges in near real-time. The invoice showed finalized charges after the period closed. These numbers had to match — and initially, they did not.
Dashboard-invoice mismatches are the most common source of billing disputes in usage-based products. The fix is architectural: both systems must derive charges from the same reconciled dataset.
ML LABS built automated reconciliation into the billing cycle. Discrepancies above a threshold trigger investigation before invoices are released — an ongoing guard, not a one-time fix.
Billing Configuration
Enterprise pricing negotiations produce constant configuration changes: new sites onboard with specific minimums, existing sites renegotiate rates, pricing toggles enable or disable charge categories per site. ML LABS built a configuration layer supporting per-site pricing adjustments, minimum thresholds, annual cap values, and category-level billing toggles — all manageable as configuration rather than code changes. Each change takes effect at the next billing period boundary with full change history for audit.
When This Scope Is Premature
Not every AI product needs a custom billing system. If pricing is a single per-unit rate with no minimums, caps, or category splits, Stripe's metered billing handles it. The complexity threshold is the interaction between pricing dimensions: the moment two or more rules must be enforced simultaneously, generic tools create more reconciliation work than they save.
First Steps
- Map your pricing rule interactions before choosing a billing tool. If more than two dimensions interact, plan for custom infrastructure.
- Build reconciliation into the architecture from the start. The first automated comparison will surface gaps.
- Separate metering from rating from invoicing. Pricing changes should only update rating config; new sites should only expand metering.
Practical Solution Pattern
Capture every billable event with tenant, site, and category metadata. Feed aggregated usage into a pricing engine that enforces all contractual rules as configuration. Generate invoices from the same reconciled dataset that powers the billing dashboard, and provide finance teams with self-service access behind role-based authentication.
This works because it separates the three concerns that tangle in generic billing: metering (what happened), rating (what it costs), and invoicing (what the customer sees). The architecture absorbs pricing model evolution without structural rework. If a usage-based billing workflow is already scoped and needs to reach production, AI Workflow Integration is the direct build path.