Skip to content
Lumean

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.

QuantityWhat it isWhere to see it
Tokena unit of a service's work volume, not moneytotal_tokens and tokens_spent in the order, summary.total_price_units in the preview
Subscription quotathe plan's token allowance for the billing periodGET /subscriptions → items[].tokens_remaining
LMCthe internal currency of your balanceprice_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/subscriptionsGet subscriptions of API key owner

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 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:

ResponseWhat happenedWhat to do
402 insufficient_balancethe balance does not have enough LMC for the top-uptop up the balance in your account or shorten the order
402 insufficient_allowancethe quota is used up and paying beyond the quota is not available for this servicewait for the next quota, change the plan or shorten the order
403 no_subscriptionthe service works with a subscription onlysubscribe to a plan
403 entitlement_missingyour plan does not include this servicechange 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.

402402 — payment required
What happened

The order was not created and no money was charged. POST /orders and POST /orders/{order}/retry return this code: both are paid for the same way. Chunk retry and regeneration also return 402 when an extra charge cannot be paid: insufficient_balance, insufficient_allowance, and for retry also insufficient_funds (the order's reserved remainder is not enough). The reason field names the cause.

What to do right now

Branch on reason, not on message: the message text can change without notice. For insufficient_balance, top up the balance. For insufficient_allowance, wait for the next quota or change the plan. Until then, the same request keeps returning the same 402.

Open the code page

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.

402payg_topup_requiredpayg_topup_required — top-up confirmation required
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_lmc and 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 new quote_token.

Open the code page
409quote_mismatchquote_mismatch — top-up price changed
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 fresh quote_token and expires_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 fresh quote_token in 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.

Open the code page

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

FieldMeaning
total_tokensthe full cost in tokens, including retries and regenerations
tokens_from_quotahow much the subscription quota covered
tokens_from_payghow much was paid from the balance
tokens_spentthe sum of the two fields above
price_unitsthe amount reserved for the order, in LMC minor units
price_formattedthe 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

Open .mdllm.md

Updated 10/18/2026 · API version 1.0.0