upto scheme, the buyer authorizes a maximum spend per call; the server settles for the actual amount, capped at that maximum. Each settlement reflects the real tokens generated, compute time, or output size.
This is the right primitive for inference billing, and it is supported on Polygon’s mainnet and Amoy facilitators today.
Who this is for:
- Hosted-model providers and inference proxies opening an agent-buyer channel
- AI platform teams replacing token-bucket subscriptions with usage-based pricing
- Commercial leaders at AI companies who need per-call billing without overcharging
How it works
Theupto scheme has two phases: at verification time, maxAmountRequired is the ceiling the buyer authorizes; at settlement time, the server passes the actual amount it computed from real usage. Replay protection comes from Permit2 nonces. Authorizations carry validAfter and deadline bounds so unsettled authorizations expire safely.
Polygon’s mainnet (x402.polygon.technology) and Amoy (x402-amoy.polygon.technology) facilitators run x402 v2, so upto works today.
Get started
Add x402 v2 middleware with theupto scheme in front of your inference route. The buyer authorizes a maximum spend; your server settles the actual amount after measuring real usage. Polygon’s mainnet and Amoy facilitators run v2.
Install
- Express
- Next.js
- Hono
Declare a maximum per call
Return anaccepts block with scheme: "upto" and a ceiling. maxAmountRequired is the maximum the buyer authorizes. USDC has six decimals, so 50000 = $0.05.
/settle endpoint. The actual amount must be less than or equal to maxAmountRequired.
Test as a buyer
Implementation
x402 Quickstart for Sellers
Add x402 v2 middleware to Express, Next.js, or Hono.
x402 How It Works
Verification vs. settlement phases, accepts shape, receipts.
Using the Polygon facilitator
Point middleware at the v2 facilitator on mainnet or Amoy.
Polygon Agent CLI
Test as a buyer with
x402-pay.