Tollstile

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 $0 releases the reservation.
  • If a variable route never calls fulfill(), nothing is charged and an error event with FULFILLMENT_MISSING is emitted.
  • Variable prices need the authorization flow and a rail with variableAmount (x402 upto, KYAPay, sessions).