How agents buy compute: the x402 payment flow

HTTP has had a status code reserved for payments since 1997: 402 Payment Required. The x402 protocol (by Coinbase) finally uses it — an AI agent hits a paid API, gets a 402 with a price, pays in USDC on Base from its own wallet, retries with a payment header, and gets the resource. No account, no API key, no human. Step through the exact flow below.

drag to orbit · scroll to zoom

Protocol steps

1GET /actor/run — the agent requests a paid resource with a plain HTTP call.
2402 Payment Required — server replies with price, asset (USDC), network (Base) and a pay-to address.
3Sign & pay — the agent's wallet signs a USDC transfer authorization (EIP-3009), settled on Base in ~2s.
4Retry with X-PAYMENT — same request, now carrying the signed payment payload in a header.
5200 OK — a facilitator verifies settlement; the server streams back the result.

Why not API keys?

Keys assume a human signed up, added a card, and manages billing. Agents are ephemeral — they may exist for one task. x402 makes payment part of the request itself: price → pay → retry. Machine-speed commerce with no onboarding.

Why USDC on Base?

Micropayments need cents-level fees and fast finality. Base (an Ethereum L2) settles in ~2 seconds for a fraction of a cent, and USDC is a dollar-stable asset, so a $0.05 API call costs $0.05 — no volatility, no invoice.

The facilitator

Servers don't need to run blockchain nodes. A facilitator service verifies the signed payment and settles it on-chain, then tells the server "paid." The server logic stays a simple middleware: if !paid → 402.

Scale today

Marketplaces like Apify have exposed 20,000+ "Actors" (scrapers, enrichers, automation tools) as x402-payable endpoints — an agent can discover a tool, pay per run, and consume the output autonomously within a single loop.
Enjoy this tool? Build your own with Super