What is x402
A way for a program to pay for one API call, with no account, no key and no subscription.
In plain words
Normally, to use a paid API you sign up, get a key and pay a monthly bill. With x402, a program just pays for the one call it makes, in USDC.
How a call works
- Your program calls the API.
- The API answers 402 Payment Required, with the price.
- Your program signs a payment for that price and calls again.
- The API checks the payment, does the work and answers.
GET /weather → 402 Payment Required (price: $0.001)
GET /weather + payment → 200 OK { "sunny": true }Why it matters for AI agents
An agent can find a new API and use it straight away. No human has to sign up, copy a key or add a card.
What you need
- A wallet with a little USDC.
- An x402 client library, for example
@x402/fetch. See Call an API.