An open-source reference for HTTP 402 — runnable, end-to-end, right in this browser tab.
Pay-per-call AI,
settled on Base Sepolia.
An HTTP 402 reference, end-to-end. The wallet signs once with EIP-712. The Rust verifier checks the signature. The AI provider runs the request. The gateway returns a signed receipt — verifiable right here, in this browser tab.
Sign once. Pay once.
Paste any text. The gateway will challenge you with a 402, your wallet signs it once, and a summary comes back with a verifiable receipt.
01 — Your text
Wallet signs the EIP-712 challenge — no on-chain transaction, no gas. Receipt is signed by the gateway and verifiable in your browser.
Payment flow and result
- 01Request
- 02Challenge
- 03Sign
- 04Verify
- 05Generate
- 06Receipt
Awaiting input
Sign once.
Get a signed answer back.
The gateway returns 402 Payment Required with a payment context. Your wallet signs it, the verifier checks the signature, the AI runs the request, and a signed receipt is returned in the response header.
Each signature, filed.
Every successful payment leaves a signed receipt. Click verify on any of them — the check runs locally in your browser, against the gateway's public key.
No receipts yet
Sign a payment above and your receipt will appear here — verifiable client-side.
The x402 dance,
in six moves.
Each step has its own failure mode and a structured error code. The status strip in the tool shows where you are in the flow, live.
- 01
Request
Client posts unsigned text to /api/ai/summarize. The gateway never charges before it has a signature.
- 02
Challenge
Gateway responds 402 with a payment context: recipient, amount, token, nonce, chainId, and timestamp.
- 03
Sign
Your wallet signs the EIP-712 typed data. No on-chain transaction, no gas — only an authorization signature.
- 04
Verify
The Rust verifier recovers the signer, enforces chain ID parity, timestamp window, and rejects replayed nonces.
- 05
Generate
Only after the signature is verified does the gateway call the AI provider. Failure here doesn't charge you.
- 06
Receipt
Gateway signs a receipt over the request and response hashes. Returned in X-402-Receipt and verifiable client-side.
A valid signature proves wallet authorization — it does not prove USDC moved on-chain. This implementation is a demo on Base Sepolia. The cryptography is real; the settlement is not.