Design Per-Token Usage Metering and Billing for an AI Cloud
Last updated: November 29, 2026
Quick Overview
Design the pipeline that turns billions of inference and fine-tuning events into accurate per-customer usage, enforces credit limits close to real time, and produces invoices that never double-count or drop usage.
Together AI
November 29, 20260
0
0 solved
Design the pipeline that turns billions of inference and fine-tuning events into accurate per-customer usage, enforces credit limits close to real time, and produces invoices that never double-count or drop usage.
Together AI prices serverless inference per million input and output tokens, with different rates per model, plus GPU-hour billing for dedicated endpoints and clusters. A metering design question checks exactly-once thinking, late and duplicate events, and the split between fast approximate enforcement and slow exact invoicing.
What the Interviewer Expects
- Emits immutable usage events with idempotency keys at the source
- Uses a durable log and deduplicates before aggregation
- Separates near-real-time balance enforcement from exact invoicing
- Versions price tables and applies the price in effect at event time
- Handles late events and corrections with reconciliation
- Exposes usage to customers in a way that matches the invoice
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How fast must credit exhaustion take effect, and what does it cost to make it faster?
- How would you bill a stream the client cancelled halfway?
- How would you reconcile metering against GPU-side logs to catch missed events?
- How would you support committed-use discounts and free-tier credits?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Inputs: one event per finished request (org, key, model, input tokens, output tokens, timestamp, request id) and periodic events for GPU-hour resources. Outputs: per-org usage by model and day, prepai...
High-Level Design
Gateways write usage events to a local durable buffer, then to a partitioned log such as Kafka keyed by org. A stream processor deduplicates by request_id, joins the versioned price table, and updat...