Authorize a maximum x402 payment and settle the actual API usage after the handler succeeds.
Use x402 upto when you know the maximum price before work but calculate the final charge afterward. It is the agentic counterpart to a capped variable checkout.
Set the settlement override only after you have computed successful usage. Keep the charged amount at or below the maximum advertised in the 402 requirements.
The buyer authorizes up to 0.10,thesuccessfulresponserecords0.04 of actual usage, and settlement charges $0.04.
Do not return billable output before middleware has verified the authorization. Define how failures, timeouts, and partial work map to a charge before you expose the endpoint.