LLM Monetization in Practice: Building an AI Credit Billing Architecture
This article explains how to design a billing system for large model services using AI credits as an internal accounting unit. It covers the shift from tracking raw call volume to measuring billable work, the core credit abstraction, task-level metering, configurable multi-modal pricing and model routing, quota governance with a pre-charge and settlement flow, and observability for cost optimization. Readers will find a practical, phased approach to making usage explainable, revenue auditable, and costs optimizable.
1. Background: From Call Volume to Billable Work
For a long time, the success of a model service was measured by call counts and monthly active users. But once model capabilities expanded from plain text to multimodal outputs like images and video, those two metrics lost much of their explanatory power. A short text inference and a long video generation can differ by several orders of magnitude in compute consumption, latency, and the cost of failed retries. Merging them into a single “usage” number makes it impossible to tell whether a product is genuinely used, and it cannot support financial accounting.
The industry has already sent a clear signal: one cloud vendor raised the priority of commercialization mid-year and increased its annual revenue target, while revenue contribution from consumer-facing applications remained limited. This shows that the user base and the revenue sources of AI often sit in different product forms. The lesson for enterprises is that a billing system must exist as a first-class citizen from day one of design, rather than being bolted on as an invoice layer after launch.
Baidu AI Cloud’s general approach to model services and billing governance is to separate metering, pricing, settlement, and auditing so each can evolve independently.
2. Core Abstraction: Treating Credits as an Internal Accounting Unit
An “AI credit” is essentially an abstract accounting unit that converts heterogeneous resources into a unified scale. Key design points:
- Credits are not currency. The exchange rate is configured on the platform side and can be adjusted at any time without affecting the interpretability of historical bills.
- Credits are integers, avoiding the accumulation of floating-point errors under high-frequency calls.
- Each task’s consumption is split into “model credits + tool credits.” For example, a search-augmented task deducts 5 credits in total: 4 for model inference and 1 for retrieval.
Illustrative data structure:
@dataclassclass UsageRecord:tenant_id: str # Enterprise tenanttask_id: str # A single auditable taskmodel_tier: str # Model tier (text/image/video)tokens_in: inttokens_out: inttool_calls: list # Retrieval, code execution, etc.credits: int # Converted creditsts: int
3. Metering Layer: Instrument by Task, Not by Request
The recommended approach is to use the task as the smallest metering unit, where a single task may contain multiple model calls and tool calls. The task ID runs through the entire pipeline and is written to a message queue, where an independent metering service aggregates it. This avoids having business services write bills directly, which would cause data pollution. A metering event should include at least the tenant, model tier, input and output size, tool type, whether the cache was hit, and the number of retries. Cache hits and failed retries must be flagged separately; otherwise costs will be systematically overestimated.
4. Pricing Layer: Multi-Modal Differentiation and Multi-Model Routing
The cost structures of different modalities are completely different, so pricing must be configurable per tier rather than hard-coded. At the same time, enterprise customers often want to choose models from different sources within the same product, so the routing layer needs to provide a unified abstraction interface:
pricing:text: { per_1k_tokens: 1 }image: { per_image: 20 }video: { per_second: 15 }tools:search: { per_call: 1 }
The routing layer maps a unified request to a specific backend and writes the actual consumption back as a metering event. The value here is that customers complete model selection within a single entry point, and tasks and artifacts stay within the platform, so subsequent tool calls and file processing continue to generate value.
5. Billing and Quota Governance
For the billing side, a two-phase “pre-charge + settlement” approach is recommended: freeze the quota before a task starts, then settle based on actual consumption when it ends and release the difference. Common enterprise-side requirements include department-level quotas, monthly caps, and over-limit degradation strategies (switching to a smaller model or queuing). All credit changes are written to an immutable ledger, and bills can be recomputed by tenant, department, or task dimension to support reconciliation and auditing.
6. Observability and Cost Optimization
You need a per-task cost dashboard that treats “credits consumed / successful output” as the core metric. Common optimization techniques include trimming prompts and context to reduce input size, batching small requests, caching deterministic results, and using offline queues to smooth peaks for non-real-time tasks. Monitoring and alerting should cover metering latency and bill drift to avoid discovering data gaps only at month-end.
7. Implementation Roadmap
In the first phase, unify metering events and task IDs. In the second phase, add configurable pricing and multi-model routing. In the third phase, fill in quotas, auditing, and the cost dashboard. The core principle is: first make usage explainable, then make revenue auditable, and only then talk about optimization and growth.
