Tokens, quotas, LMC and PAYG
How an order is paid for — subscription quota, balance top-ups and 402 responses.
Orders are paid for in tokens. Tokens come out of your subscription quota first. If the quota is not enough, the remainder is charged to your LMC balance.
| Quantity | What it is | Where to see it |
|---|---|---|
| Token | a unit of a service's work volume, not money | total_tokens and tokens_spent in the order, summary.total_price_units in the preview |
| Subscription quota | the plan's token allowance for the billing period | GET /subscriptions → items[].tokens_remaining |
| LMC | the internal currency of your balance | price_formatted in the order, GET /wallets |
Cost before you order
curl -s -X POST "$BASE/orders/chunks/preview" -H "X-API-KEY: $KEY" \
-H "Content-Type: application/json" \
-d '{ "template_id": "<UUID>", "input_text": "…" }'summary.total_price_units is the number of tokens POST /orders will charge for the same text.
summary.cost_lmc is the same cost in LMC; when it cannot be calculated, the field is absent.
The preview is free and does not create an order.
GET /subscriptions shows the remaining quota:
Get subscriptions of API key owner
The response contains active subscriptions only. The remainder is in items[].token_allowance,
tokens_used and tokens_remaining.
Get Usage Limits
GET /usage lists your subscription limits: limit_type, limit_value, used, remaining,
period_end, resets_in. For a single service, use GET /usage/{service},
where {service} is the numeric service_id from the GET /usage response.
GET /wallets returns your LMC balance and needs the same billing.read scope; money movements are in GET /ledger-transactions.
When the quota runs out
{
"data": {
"tokens_from_quota": 1200,
"tokens_from_payg": 300,
"tokens_spent": 1500
}
}The remainder is charged to your balance automatically, and the order is created right away.
tokens_from_quota and tokens_from_payg show how much the quota covered and how much came from
the balance.
Each service has its own setting for paying beyond the quota. If it is closed for a service, you get
402 insufficient_allowance instead of a charge.
When an order cannot be paid for, it is not created and nothing is charged:
| Response | What happened | What to do |
|---|---|---|
402 insufficient_balance | the balance does not have enough LMC for the top-up | top up the balance in your account or shorten the order |
402 insufficient_allowance | the quota is used up and paying beyond the quota is not available for this service | wait for the next quota, change the plan or shorten the order |
403 no_subscription | the service works with a subscription only | subscribe to a plan |
403 entitlement_missing | your plan does not include this service | change the plan |
POST /orders/{order}/retry and chunk regeneration are paid for the same way. A 429 with
reason: limit_exceeded is a subscription limit, not a payment issue: see
Limits and the 429 code.
- What happened
The order was not created and no money was charged.
POST /ordersandPOST /orders/{order}/retryreturn this code: both are paid for the same way. Chunk retry and regeneration also return402when an extra charge cannot be paid:insufficient_balance,insufficient_allowance, and for retry alsoinsufficient_funds(the order's reserved remainder is not enough). Thereasonfield names the cause.- What to do right now
Branch on
reason, not onmessage: the message text can change without notice. Forinsufficient_balance, top up the balance. Forinsufficient_allowance, wait for the next quota or change the plan. Until then, the same request keeps returning the same 402.
Explicit top-up confirmation mode
The platform can temporarily switch on a mode where paying beyond the quota needs consent. In that
mode an order beyond the quota is not created right away, and the server answers 402 with the
price:
{
"success": false,
"message": "…",
"reason": "payg_topup_required",
"shortfall_tokens": 300,
"shortfall_lmc": 3.6,
"shortfall_lmc_minor": 360000000,
"quote_token": "q_9f8b2c1a4d3e",
"expires_at": "2026-10-18T12:01:00+00:00"
}To agree, repeat the same request with confirm_payg_topup: true and the quote_token from the
response:
curl -s -X POST "$BASE/orders" -H "X-API-KEY: $KEY" \
-H "Content-Type: application/json" \
-d '{ "template_id": "<UUID>", "input_text": "…",
"confirm_payg_topup": true, "quote_token": "q_9f8b2c1a4d3e" }'A quote is valid for 60 seconds. Repeating the request without confirmation returns a new 402 with
a new price. If the top-up got more expensive by the time of the charge, you get 409
quote_mismatch with a fresh quote_token and expires_at: repeat the request with them. Outside
this mode, confirm_payg_topup and quote_token are ignored.
- What happened
The order was not created and no money was charged. Instead, the server sent the top-up price. Body:
reason: "payg_topup_required",shortfall_tokens,shortfall_lmc,shortfall_lmc_minor,quote_token,expires_at. This response comes only in explicit top-up confirmation mode. By default, the amount beyond the quota is charged automatically.- What to do right now
Show the user
shortfall_lmcand get explicit consent. An automatic retry here means charging money without the user knowing. The quote is short-lived: 60 seconds by default (expires_at). If it has expired, a request without confirmation returns a new 402 with a newquote_token.
- What happened
The confirmed top-up did not go through: the order was not created and nothing was charged. Body:
reason: "quote_mismatch",actual_lmc_minor(the current price),quoted_lmc_minor(the price in the quote), and a freshquote_tokenandexpires_at. This code comes only in explicit top-up confirmation mode.- What to do right now
Show the user the new price and get consent again. The new price is
actual_lmc_minor, in LMC minor units. The freshquote_tokenin this response is already issued for the new amount. The old token will not work: while the price is above the quote, a request with it returns 409 again.
Do
Show the user shortfall_lmc, wait for their consent, and repeat the request with the quote_token
from the same response.
Don't
Retry a 402 with confirm_payg_topup: true automatically: that charges money without the user
knowing.
Minor units
Money fields with the _minor suffix, as well as price_units, are integers in minor units. The
real value is minor / 10^precision. Take precision from the data: currency_asset.precision on
the order, lumc_precision on the service. For example, shortfall_lmc_minor: 360000000 with
precision: 8 is 3.6 LMC.
To show amounts to users, use the ready-made shortfall_lmc and price_formatted.
Payment details in the order
| Field | Meaning |
|---|---|
total_tokens | the full cost in tokens, including retries and regenerations |
tokens_from_quota | how much the subscription quota covered |
tokens_from_payg | how much was paid from the balance |
tokens_spent | the sum of the two fields above |
price_units | the amount reserved for the order, in LMC minor units |
price_formatted | the same amount, ready to display |
A zero share comes as null, not 0. For an order fully covered by the quota, tokens_from_payg
is null.
You cannot top up the balance or buy a plan with an API key. Do it in your account: wallet, plans, account limits.
This page for AI
Updated 10/18/2026 · API version 1.0.0