Protocol Walkthrough

x402: How AI Agents Pay for Their Own Tools

HTTP has had a status code reserved for payments since 1997 — 402 Payment Required. The x402 protocol finally uses it, letting agents buy API calls with stablecoins, no accounts or API keys. Step through the handshake below.

Step 0 / 5Press "Next step" to send the first request.
$0.010 / call 1,000 calls/day ≈ $300/mo

The five-message handshake

  1. Request. The agent calls GET /api/geocode like any HTTP client — no API key, no signup.
  2. 402 response. The server replies 402 Payment Required with a payload: price ($0.01), asset (USDC), network, and the address to pay.
  3. Signed authorization. The agent's wallet signs an X-PAYMENT header authorizing exactly that amount — a signature, not a broadcast transaction.
  4. Verification & settlement. The server (or a facilitator service) verifies the signature and settles on-chain. USDC on a fast L2 finalizes in ~2 seconds for a fraction of a cent in fees.
  5. 200 OK. The original response is returned with the data. Total added latency: typically under a few seconds.

Why not just credit cards?

Card rails charge roughly $0.30 + 2.9% per transaction. On a $0.01 API call, fees would be 3,000% of the price. Stablecoin micropayments make per-call pricing viable:

• $0.01 call via card ≈ $0.31 total → 31× the price
• $0.01 call via x402 on an L2 ≈ $0.0102 total → 1.02× the price

That 30× gap is why agents "paying for themselves" only works with machine-native payment rails. It also removes the human bottleneck: no checkout page, no card on file, no monthly invoice — the agent discovers a tool, pays, and moves on.

Budget math for autonomous agents

Use the price slider above. At p dollars per call and n calls per day, monthly spend is p × n × 30. A research agent making 1,000 calls/day at $0.01 spends about $300/month — comparable to a SaaS seat, but pay-per-use with a hard wallet cap. Sensible guardrails: per-transaction ceiling, daily budget, and an allowlist of payees.

Enjoy this tool? Build your own with Super