Meterline: usage billing and prepaid credits

Lumen AI, an inference API company, bills tokens in price tiers, GPU-seconds through event-based billing, and prepaid credit packs on Maxio Advanced Billing.

Open Meterline →

Meterline's Usage Pulse: token usage across the billing period drawn over the price tiers, with a tier ladder of customers

The story

Lumen AI is a fictional company selling an inference API. It bills its own customers on Maxio Advanced Billing with a monthly platform fee, input and output tokens metered in price tiers (in millions of tokens, MTok), GPU-seconds through event-based billing, and prepaid "inference credit" packs that are drawn down. Meterline is the console Lumen's billing engineer uses to send usage, watch each customer's tier and credit balance, and preview the next invoice.

At a glance
Use caseUsage-based billing, tiered pricing, event-based billing, prepaid credits
SDK operations14
Live appmxo-meterline.pages.dev

Screens

ScreenWhat you see and doSDK calls
Usage PulseA live token counter over the price-tier bands, with a run-rate projection and the date each customer crosses into the next tier. Beside it, a tier ladder places all 12 customers on their tiersubscriptions.listSubscriptions, components.listComponents, subscriptionComponents.listSubscriptionComponentsForSite, subscriptionComponents.listUsages
IngestSend metered usage, or GPU-second events one at a time or as a batch of 25, and watch the meter move across tier breakssubscriptionComponents.createUsage, subscriptionComponents.recordEvent, subscriptionComponents.bulkRecordEvents
CreditsA burn-down of each prepaid credit balance with a forecast of the run-out date. Preview and then add a top-up, or extend an expiry datesubscriptionComponents.listAllocations, subscriptionComponents.previewAllocations, subscriptionComponents.allocateComponent, subscriptionComponents.updatePrepaidUsageAllocationExpirationDate
Projected invoiceThe next renewal as a waterfall: platform fee, tokens split by tier, GPU-seconds, credits applied, tax and totalsubscriptionStatus.previewRenewal, subscriptionComponents.listSubscriptionComponents, entitlements.readSubscriptionEntitlements

SDK operations

OperationSDK methodUsed for
List subscriptionssubscriptions.listSubscriptionsThe customer roster
List componentscomponents.listComponentsToken, GPU and credit components with their price tiers
List subscription components for a sitesubscriptionComponents.listSubscriptionComponentsForSiteEvery customer's usage this period in one call
List usagessubscriptionComponents.listUsagesThe usage history behind the meter
Create usagesubscriptionComponents.createUsageRecord metered tokens
Record eventsubscriptionComponents.recordEventOne GPU-seconds event
Bulk record eventssubscriptionComponents.bulkRecordEventsA batch of GPU-seconds events
List allocationssubscriptionComponents.listAllocationsCredit top-ups and their expiries
Preview allocationssubscriptionComponents.previewAllocationsPrice a top-up before it is made
Allocate componentsubscriptionComponents.allocateComponentAdd prepaid credits
Update prepaid allocation expirationsubscriptionComponents.updatePrepaidUsageAllocationExpirationDateExtend a credit pack
Preview renewalsubscriptionStatus.previewRenewalThe projected invoice
List subscription componentssubscriptionComponents.listSubscriptionComponentsOne customer's components with historic usage
Read subscription entitlementsentitlements.readSubscriptionEntitlementsThe plan's entitlements

Code: record usage and preview the invoice

// Metered tokens, addressed by the subscription's reference
const { usage } = await client.subscriptionComponents.createUsage({
  subscriptionIdOrReference: "lumen-orbital-health",
  componentId: inputTokensId,
  body: { usage: { quantity: 120, memo: "Hourly sync 14:00" } },
});

// The next invoice, line by line
const { renewalPreview } = await client.subscriptionStatus.previewRenewal({ subscriptionId });

Errors shown on purpose

  • Maxio 422s: usage on a canceled customer, drawing more credits than remain, a zero-credit top-up preview, moving an expiry date earlier, and previewing the renewal of a canceled subscription.
  • App rules: negative usage, an unknown subscription reference, a GPU event over 24 hours and a top-up over 50,000 credits are blocked before Maxio sees them.

On this page