Skip to main content
Every plan: AI answers included. Your dashboard: what each workspace’s AI cost you this month, and across all of them.
Ledger shows what each customer costs you in AI, so you know your margin on every account and every plan. Track each model call’s cost to Ledger as it happens, in a fixed unit of $0.0001, and Ledger keeps the total per customer. Make each workspace its own Ledger customer to see the cost per workspace. Pick the feature type by whether the customer pays for that cost:

With a metered feature

An unlimited: true item allows every use and records its quantity, so the feature tracks your cost without limiting or billing the customer.
After each call, track its cost. Use the call’s own ID as request_id, so a retry records it once.
Read the period’s total from the customer. balance.used adds up every quantity tracked since the billing period began:
Response (features entry)
$184.27 against a $49 plan. resetsAt is when the period ends and used starts again from 0, so read it before then to keep each period’s figure.

With a credits feature

When customers pay for usage at cost, the cost is already in Ledger: each call’s quantity is what it cost you, in credits (Prepaid dollar balance). Read a month’s total per customer:
Response
Leave out customerId for the month across every customer. GET /v1/usage lists each call with its chargedCredits, for a breakdown by request.

Rules

  • quantity is a whole number, at least 1 on a metered feature. Round each call up to the next $0.0001; that adds at most $0.0001 per call.
  • One track is at most 2,147,483,647 units, $214,748.36 at this scale.
  • Usage totals’ chargedCredits sums credits features. A metered feature’s units are in its balance; totals count its calls in events and charged.
  • Totals are by UTC month of the customer’s time; balance.used is by billing period.
  • Each workspace is a customer for its own totals. Entities split one customer’s credits within its totals.