Make your AI agent pay for what it needs: x402 in 5 minutes

The useful web hides behind signups, captchas, and API keys — none of which an autonomous agent can obtain mid-task. x402 fixes this with the HTTP status code that sat unused for thirty years: 402 Payment Required. Settlement infrastructure exists from Coinbase and Stripe; this guide uses a live service (agent402.tools) you can pay right now.

The protocol in one paragraph

Your client calls a paid endpoint. The server replies 402 with a machine-readable quote — price, asset (USDC), network (Base), pay-to address. Your client signs a USDC transfer authorization from its own wallet (no gas needed; the facilitator sponsors it) and retries the request with the payment header. The server verifies, settles on-chain, and serves the result. Seconds, end to end. The payment is the identity — no account ever existed.

See a quote (free)

curl -i -X POST https://agent402.tools/api/extract \
  -H 'Content-Type: application/json' -d '{"url":"https://example.com"}'
# HTTP/2 402 … {"x402Version":2,"accepts":[{"price":"$0.005","network":"eip155:8453",…}]}

Pay it (JavaScript)

Fund a wallet with a little USDC on Base (the payer needs no ETH), then:

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.AGENT_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/extract", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ url: "https://example.com/article" }),
});
console.log(await res.json()); // { title, markdown, wordCount, … }

That one wrapped fetch now covers 1,000+ tools — browser rendering, live search, PDFs, durable memory — each a flat $0.001–$0.02 per call. The full catalog is machine-readable at /api/pricing.

Or from the command line

Stripe's open-source purl is "curl for paid endpoints":

purl wallet add --name me --type evm -k 0xYOUR_KEY -p pass --set-active=true
purl "https://agent402.tools/api/convert/kilometers-to-miles?value=42"

No wallet? Pay with CPU

About 1,040 of the tools also accept proof-of-work — a sub-second sha256 puzzle solved by the caller, no money involved:

import { createHash } from "node:crypto";
const lz = (b) => { let t = 0; for (const x of b) { if (!x) { t += 8; continue; } t += Math.clz32(x) - 24; break; } return t; };
const c = await (await fetch("https://agent402.tools/api/pow/challenge?slug=hash")).json();
let n = 0;
while (lz(createHash("sha256").update(c.challenge + ":" + n).digest()) < c.difficulty) n++;
const res = await fetch("https://agent402.tools/api/hash", {
  method: "POST",
  headers: { "Content-Type": "application/json", "X-Pow-Solution": c.token + ":" + n },
  body: JSON.stringify({ text: "hello world" }),
});

Or skip all of this: paste https://agent402.tools/mcp into Claude as a custom connector and the free tier just works, or run npx -y agent402-mcp with an AGENT_KEY for the full catalog with spend caps enforced before any payment is signed.

Why this matters

Per-call payment with no accounts means an agent can acquire capabilities at the moment it discovers it needs them — and the seller can prove every cent of revenue on-chain. Every claim in this guide is verifiable: the server is open source and settled calls land at a public wallet.

← All guides · agent402.tools — 1,000+ pay-per-call tools for AI agents.