x402: How AI Agents Pay for API Calls with Crypto Micropayments
Dev.to AI
•
Generative AI
X402 is an HTTP payment protocol that lets AI agents pay for individual API calls without ever creating an account, entering a credit card, or requesting an API key. When an agent requests a paid endpoint, the server returns 402 Payment Required with a JSON envelope describing the facilitator, token, amount, and network. The agent signs a stablecoin payment with its wallet, retries the same request with an X-PAYMENT header, and gets the response in a single HTTP round trip.