Skip to main content
You can’t price some work until it is done: tokens generated, pages extracted, seconds of processing. Charging a flat worst-case rate overcharges everyone else; metering after the fact leaves the buyer unauthorized. ZeroClick’s answer is a ceiling: declare the most the request could use, let the buyer authorize that maximum, and settle at what the request actually used.

Charging up to a maximum

Declare the ceiling with maxQuantity instead of quantity:
The buyer authorizes up to the ceiling, and the payment settles at the actual usage you report on the response: a ceiling never overcharges. The SDK rejects a usage item that declares both quantity and maxQuantity before any network call. You can also declare neither: the item then defers to the meter’s configured Max usage per request (defaultMaxQuantity on the plan’s meter price). That keeps the ceiling in your catalog instead of your code. If the meter has no configured maximum, the allowance check denies with meter_not_priced. On the buyer’s side, a ceiling is payable only on the reserve payment rails: the agent authorizes the maximum and pays the actual amount you settle. An exact quantity lets ZeroClick offer the immediate-settle scheme more clients can pay today, so when you know the size, prefer fixed charges. See payment protocols.

Settle at the actual amount

A ceiling has no settled quantity until you report one. On a pay-per-call payment, report it on the response: that is the only place the payment settles, so know the actual by the end of the handler. Only a buyer on a credit, subscription, or free-trial plan can be billed asynchronously for work that finishes later.
The settled quantity can be anywhere from zero up to the declared ceiling. An unreported ceiling on a paid, delivered response settles at zero (safe for the buyer, unbilled for you), and the rest of the hold is released at once. A 202 counts as delivered. A report sent later cannot reopen the payment, so the header on the response is what turns the work into revenue. See settle usage for the header rules (2xx only, stripped by ZeroClick).

Go: Meter takes fixed quantities only

Go’s Meter middleware settles exactly what it declares, so it accepts fixed quantities only. Handed an UpTo item, it panics at wire-up: a ceiling has no settled quantity, and the middleware would otherwise bill zero, silently, on a delivered 200. You have two working shapes: call Guard yourself and settle explicitly on the response, or keep Meter for a fixed per-request charge and report the variable part after responding. The second shape bills the variable part only to buyers on a credit, subscription, or free-trial plan. For a pay-per-call buyer the report fails with 404 access_not_found, and they pay the fixed part alone.
The fixed charge keeps the immediate-settle scheme available to buyers; for plan buyers, the report settles the variable part. The same fixed-plus-reported split works in any language when you know the variable amount only after the response, with the same limit: pay-per-call buyers are billed the fixed part only. See settle usage for the reporting rules.