How software pays for the web.

x402 puts a price in an HTTP answer. An agent asks, gets 402 Payment Required with a quote, pays it in USDC and gets the data, in about a second, with no account or API key.

What happens in each step
  1. Ask. The agent sends an ordinary request, with no login and no key.
  2. Price. The server answers 402 with a quote in the payment-required header: the amount, the token (USDC), the network (Base), the wallet to pay and how long the offer lasts.
  3. Pay. The agent's wallet signs a permission for exactly that amount (EIP-3009, so it pays no gas) and sends the same request again with it in a payment-signature header.
  4. Deliver. The server has a facilitator check the signature and balance, does the work, settles the payment on-chain and answers 200 with the result and a receipt.

See a real price tag

Press the button and your browser asks one of our tools for data without paying. Our server answers with the price, just as it would to an agent. Nothing is charged, and there is no wallet on this page.

Waitingdns_lookup
$?
Paid in
USDC
Network
Base
Offer lasts
-
Paid to
-

Press the button to get a quote.

The raw answer
Press the button to see the real 402 answer.

Steps 3 and 4: let your code pay

The official x402 client wraps fetch. When a request comes back 402, it signs the quoted payment and retries, so your code looks like any other API call:

Code17 lines
// npm i @x402/fetch @x402/evm viem
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

// A wallet with a few dollars of USDC on Base. It never needs ETH: the facilitator pays the gas.
const account = privateKeyToAccount(process.env.AGENT_KEY);
const pay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});

// Same request as before. On a 402 it signs the quoted payment and retries by itself.
const res = await pay("https://aipaygen.com/v1/dns_lookup", {
  method: "POST", headers: { "content-type": "application/json" },
  body: JSON.stringify({ domain: "stripe.com" }),
});
console.log(await res.json()); // the result, plus a payment-response header with the receipt

Agents that speak MCP can skip the code: connect https://aipaygen.com/mcp and every paid tool works the same way. Prefer prepaid credit? Buy credit with a card and use the key instead; the paid_fetch tool then buys from any x402 site for you.

Why 402 sat unused for nearly 30 years

Every web response carries a status code: 404 for not found, 500 for a server error. Since 1997 (RFC 2068) there has also been 402 Payment Required, marked "reserved for future use". It stayed unused until x402 arrived in 2025, because nobody could charge a cent online when a card payment costs about 30. x402 is the missing piece: a price in the 402 answer and a signed stablecoin payment in the retry. No accounts and no subscriptions, which is what AI agents need, because they can't fill in a card form.

Why stablecoins

The payment has to be tiny, instant and made by software. A card payment costs about 30 cents plus 3%, so a 1-cent charge is impossible. USDC on Base costs a fraction of a cent to settle, works on weekends, and an agent can hold a wallet with a spending limit set by its owner, which it can't do with a bank account.

USDC in one minute

What it is. USDC is a digital dollar issued by Circle, a US company: each one is designed to be worth $1 and is backed by cash and short-term US Treasuries. It lives on blockchains; we use Base, a low-fee network built by Coinbase.

If you run a site. You only need an address to be paid to, which is free to make: a self-custody wallet such as Coinbase Wallet or MetaMask, set to the Base network. Paste the address into your setup. Payments go straight to it, never through us, and you can turn USDC into dollars at an exchange like Coinbase.

If you run a crawler or an agent. Put a few dollars of USDC on Base in a wallet your software controls, and set a spending limit. It needs no ETH for fees: the payment service pays them. No wallet? Buy credit with a card instead and use an API key; AIPayGen pays sites for you.

Sell with x402

Have an API? Put it behind our gateway and get paid per call, straight to your wallet. Have a website? Charge AI crawlers per page while people browse free.