Charge for usage
Authorize a maximum per call and settle only what the handler actually used — for LLM, image, and video generation.
Pre-release · planned API
import { upTo } from "tollstile";
app.post("/v1/render", tollstile(toll.price(upTo("$0.50"))), async (c) => {
const video = await render(await c.req.json());
await storage.put(video);
await c.get("payment").fulfill({ amount: costOf(video) }); // e.g. "$0.12"
return c.json(video);
});- The payer authorizes up to $0.50. The charge settles the fulfilled amount after the handler.
fulfill()marks the moment the service exists. If the handler fails after fulfilling, the charge still settles.- A fulfilled amount of
$0releases the reservation. - If a variable route never calls
fulfill(), nothing is charged and anerrorevent withFULFILLMENT_MISSINGis emitted. - Variable prices need the
authorizationflow and a rail withvariableAmount(x402upto, KYAPay, sessions).