ServiceListing and computed deterministically by the shared priceFor(model, estimate) function. Every endpoint in your listing carries a PricingModel that maps a WorkEstimate — token counts or discrete units — to an exact amount in atomic units of the settlement asset. The same function runs on both the seller and the buyer side, so both parties can independently verify what a request should cost before any payment is committed.
Pricing Model Types
Agora402 supports three pricing model kinds. Choose the one that best matches how your endpoint consumes resources.Flat Pricing
Flat pricing charges the same fixed amount for every request, regardless of payload size or output length. Use it for endpoints where cost does not vary per call.Flat pricing model
amount is the exact number of atomic units (tinybars for HBAR) charged per request. There are no variables — every call to the endpoint costs exactly this amount.
Per-Token Pricing
Per-token pricing is designed for LLM inference endpoints. It charges a base fee once per request, then adds a cost proportional to the number of input tokens and the number of output tokens budgeted.Per-token pricing model
maxOutputTokens value comes from the max_tokens field of the request body — it is a budget, not an actual count, so the price is deterministic before the response is produced.
Before issuing a 402 challenge, the seller calls estimateChatInput(body) from the shared package to read messages from the request body and compute inputTokens and maxOutputTokens. This means two prompts of different lengths receive different 402 amounts on the same endpoint.
Per-Unit Pricing
Per-unit pricing is suited for data or compute endpoints that can be quantified in discrete countable units — queries, seconds, kilobytes, and so on.Per-unit pricing model
amountPerUnit × units, with a minimum of 1 unit. If the buyer’s estimate does not specify units, the seller defaults to 1. The unit field is a human-readable label recorded in the receipt’s usage field for auditing purposes.
Understanding Atomic Units and HBAR
Allamount fields in pricing models are decimal strings representing atomic units of the settlement asset:
- For native HBAR: 1 HBAR = 100,000,000 tinybars (8 decimal places)
- For HTS tokens: atomic units depend on the token’s
decimalssetting
formatAmount from the shared package to convert atomic amounts to human-readable strings for display:
Formatting amounts for display
Parsing amounts without floats
Pricing Model Reference
PricingModel type definition
PricingModel type definition
string fields that represent amounts must be non-negative decimal integers with no leading zeros (e.g. "1000000", not "1_000_000" or "1e6").WorkEstimate type definition
WorkEstimate type definition
0 for per-token pricing and 1 for per-unit pricing.All pricing arithmetic uses native JavaScript
BigInt. Floating-point numbers never touch monetary amounts anywhere in the stack. This eliminates rounding errors that could silently over- or under-charge buyers across thousands of micro-payments.