Metering
Products built on models have a cost on every request. Metering records each unit of work against the person or team that caused it, checks it against their plan, and keeps a ledger of credits. Send token counts with each call and you can see your margin per customer, not just your total spend.
What Metering does
Usage events
One call for each unit of work, under any metric you name. Totals by user, organization, metric and period are ready to read.
Limits from plansIn preview
Plans set quotas. Check what remains before running expensive work, and get a clear refusal when a customer is over.
Credits and top-upsIn preview
Prepaid balances, top-up checkout, grants, expiry and refunds. Every movement is an entry in an append-only ledger.
Model cost pass-throughIn preview
Report model and token counts. Dianthan prices them at current provider rates and applies your markup in credits.
Margin per customerIn preview
Revenue set against model spend, for each user, organization and plan, so you can see which accounts cost more than they pay.
Spend alertsIn preview
Get notified when a customer, an app or your whole account passes a threshold you set.
In your code.
Record a unit of work against the person who caused it.
await dianthan.usage.record({
userId: session.userId,
metric: "export.pdf",
quantity: 1,
});Better with.
What Metering does once another system is switched on in the same app.
- Billing
Plans carry quotas, and usage counts against them as it happens.
- Observe
Model spend sits next to activity, so you can see a costly account before the invoice does.
- Messaging
Tell a customer they're running low on credits before they run out.
- Models
Usage you meter and model spend sit on the same customer, so a plan's limits can cover both.
Endpoints.
The main routes. The API reference lists every parameter and response.
- POST /v1/usage/events
- GET /v1/usage
- GET /v1/usage/:metric
- GET /v1/organizations/:id/usage
- GET /v1/credits/balance
- POST /v1/credits/grants
- POST /v1/credits/top-up
Included in the plan.
Metering is part of every account: free within hard limits, then included in the $29 plan that covers every system and every app.
Included
1 million usage events. Credit ledger. Model price table.
Beyond that
$2 per extra million events.