Pro: $20 a month, including $10 of AI usage, then usage at cost.Sell AI usage in dollars, at cost or with a margin, across Anthropic, OpenAI, Google and more. Your backend reports each model call’s model and tokens. Ledger prices them from its model price table (or your own prices), adds your markup, and charges the dollars to the customer’s balance. You never work out a cost yourself.
The catalog
Anai_tokens feature prices each call. The catalog’s creditsPerUsd makes the shared credit pool a dollar balance: at 100,000 credits per dollar (the recommended value), one credit is $0.00001 and `monthlyCredits: 1_000_000` is $10.
creditsPerUsd is one of 100, 1,000, 10,000, 100,000 or 1,000,000. Other features on a dollar pool keep their fixed creditCost, now readable as dollars: an image at creditCost: 4000 costs $0.04.
The shared pool or its own balance
An AI feature spends one of two balances, set when it’s created and locked afterwards:Markup
A percent with up to two decimals, from -100 to 1,000. Ledger uses the first that applies:modelMarkupPercentfor the call’s model ID;providerMarkupPercentfor its provider (the model ID up to the first/);- the feature’s
markupPercent; -
Model prices
Ledger keeps a model price table, generated from models.dev for Anthropic, OpenAI, Google, xAI, Mistral, DeepSeek and OpenRouter. A daily job proposes every price change for review, and the table applies to calls after it deploys. Model IDs areprovider/model as models.dev lists them: anthropic/claude-sonnet-4-5, openai/gpt-4o, openrouter/anthropic/claude-opus-4.6. Dated IDs work where models.dev lists them. An unknown ID returns 400 model_not_found, so a typo never prices at 0.
Prices are per million tokens, for input, output, cache reads, cache writes, reasoning, audio input and audio output. A pool a model doesn’t price uses its input rate (cache, audio input) or output rate (reasoning, audio output). Some models have a long-context tier: when a call’s input, cache read and cache write tokens pass its threshold (200,000 tokens, for example), every pool uses the tier’s rates.
Every charge records the table’s version and the rates it used, so a past charge stays explainable after prices change.
Your own prices
The catalog’smodels prices your own custom/ models, or sets a negotiated rate for a listed one. Dollars per million tokens, as decimal strings:
ledger.catalog.json
custom/ model sets input and output; the other pools are optional and use the same rates as above. A charge at your own price records priceVersion: "org". Get the catalog reads creditsPerUsd and models back.
Track a call
Send the model and the call’s tokens with the track. Each pool counts its tokens once:input excludes cached tokens, output excludes reasoning tokens.
Response
modelandtokensare the amount. Ledger prices them, as it pricesquantityatcreditCoston other features.tokens.inputandtokens.outputare required;cacheRead,cacheWrite,reasoning,audioInputandaudioOutputare optional.chargedUsdis the charge for any AI feature, on either balance. On the pool,chargedCreditsis the same charge in credits. On an own balance,chargedCreditsis 0 (the pool is untouched),chargedQuantityis the credits charged to the feature, andbalancecarriesincludedUsd,usedUsdandremainingUsd.- Rounding. A call is rounded up once, to a whole credit: at 100,000 per dollar, by under $0.00001. A call that costs anything is never charged 0.
- Retries. A repeat
request_idreturns the first call’s charge and itsaiblock, whatever tokens the retry carries.
A call past the balance
A model call has already happened when it’s tracked, so Ledger charges what the balance and any overage under the cap cover, and reports the rest asuncoveredCredits, with 200. The call is recorded with both numbers, and the next check is refused, so an empty balance stops the next call before it runs.
Check and reserve
check takes the same model and tokens as an estimate: prompt tokens plus max_tokens of output. Without one, an AI check asks whether anything is left, at a cost of 1 credit. On the pool, creditCost is the priced estimate; on an own balance it’s 0 and the estimate is compared with balance.remaining. The response adds ai, costUsd, and availableUsd on the pool.
With reserve, the hold is the priced estimate. The track that settles it sends the real model and tokens under the same request_id: up to the hold it always succeeds, and above the hold it charges what fits and reports the rest as uncoveredCredits.
Entities
On a pool feature, a call withentityId spends the entity’s allowanceCredits first, then the shared pool under its capCredits, as any credits track; on a dollar pool those amounts are dollars too. On an own balance the entity is recorded, and the customer’s feature balance is spent. See Entities.
Overage and invoices
“Usage at cost” isoverageUnitAmountCents: 1, overageBillingUnits: 1000 at 100,000 credits per dollar: one cent per cent of usage. Overage counts whole billing units, so keep the unit at a cent: at 100 per 100000, $2.35 of usage would count as $3.00, against the cap and on the invoice. It works on the plan (the shared pool) or on an own-balance item, and one overage cap in cents covers all of a customer’s overage.
On a dollar balance the invoice line shows dollars: “Pro – overage, $12.35" for the pool, "Pro – Assistant overage, $12.35” for an own balance. Overage has the cap and the rest of the rules.
Mapping provider usage
The usage log
GET /v1/usage and GET /v1/usage/{id} show each AI call’s ai: the model, tokens, base cost, markup, cost, price version, and the credits it was priced at, charged and left uncovered.
Rules
- Price AI features with
modelandtokens. A track sends them in place ofquantity, and a reserve sends them as its estimate; a rawreserve.quantityreturns400 invalid_request. - Give own-balance features an item on each plan that sells them; without one the call returns
feature_not_in_plan. creditsPerUsdstays fixed once a balance has grants (409 credits_per_usd_locked), so every customer’s balance keeps its value.- One grant or charge holds at most 2,147,483,647 credits: $21,474.83 at 100,000 per dollar. The catalog refuses a plan, pack or item above that, with the limit in dollars.
- A feature keeps its
balance. To switch betweenpoolandown, make a new feature. - A track refused for its AI fields charges nothing and logs a failed usage event with the reason.
Related
- Credits: the shared pool an AI feature spends by default.
- Prepaid dollar balance: a dollar balance for costs you work out yourself.
- Reservations: hold an estimate, settle the real cost.
- Overage: the cap and how a period’s overage rounds.