Tutorial

Pay per tool call with x402 on Base

Call a metered tool with no key and no signup — sign a USDC-on-Base micropayment inline and the same call goes through.

Payments 5 min read

The 402 flow

Call any metered tool with no key and no payment, and the gateway answers honestly instead of just failing:

POST /tools/mortgage   (no X-API-Key, no signature)
→ 402 Payment Required

The response body is an x402 v2 payment-requirements object: the exact USDC amount, the Base network (chain 8453), and the EIP-3009 transferWithAuthorization terms it wants signed. The full machine-readable manifest lives at /.well-known/x402.

Sign, retry, done

An x402-capable client signs the authorization and retries the same call with a PAYMENT-SIGNATURE header (legacy RPC clients use X-Payment with a settled tx hash instead). No signup, no session — the payment and the call happen in the same round-trip. Prices run in the fractions-of-a-cent range per call; see /pay for the live range, pulled straight from the tools registry rather than quoted from memory.

Free key vs x402 — when to use which

A free key (/keys/issue) is simpler for a human-run integration doing occasional calls. x402 is the fit for an autonomous agent that already holds a funded Base wallet and would rather pay per call than manage a key. Both hit the same tools — this is a settlement choice, not a feature difference. See Get a free API key — or skip it and pay per call for the key-based side.

Tools used in this guide