How AI agents pay for APIs: agentic payments and the x402 pattern
Autonomous AI agents are starting to call APIs on their own — but the payment model behind most APIs assumes a human signed up, entered a card, and provisioned a key in advance. An agent that discovers a useful endpoint at runtime has no such account. The x402 pattern revives the long-dormant HTTP 402 "Payment Required" status code to let an agent pay for a single request inline, with a stablecoin micropayment, no account needed.
Why API keys break for agents
Traditional API access requires pre-registration: create an account, add a payment method, generate a key, manage quotas. That flow assumes a human operator and a long-lived relationship. An autonomous agent composing a task from services it finds on the fly cannot pause to have a human sign up for each one. The result is that agents are stuck behind whatever keys were provisioned for them, unable to transact for new resources at machine speed. Pay-per-request removes the account from the critical path.
How the 402 flow works
The client requests a resource; the server responds with HTTP 402 and a payment challenge describing the price and how to pay. The agent settles the amount — a stablecoin micropayment such as USDC — and retries with proof of payment; the server verifies and returns the resource. Payment becomes part of the request itself, not a prerequisite set up hours earlier. In a pay-per-proof design the priced resource is a cryptographic signature: the agent pays a micropayment and receives a post-quantum-signed attestation it can present elsewhere.
Honest scope
x402 solves account-free, per-request settlement between an agent and a service; it does not replace identity, authorization or rate-limiting policy, which you still define. Settlement is in stablecoin on a public chain, so it is non-custodial and final — there is no chargeback, which suits machine payments but means the service must deliver correctly. The signatures priced by a pay-per-proof endpoint are resistant to known attacks per NIST, not unbreakable; the pattern buys account-free commerce at machine speed, not a trust guarantee about the service itself.
Try it yourself — live, free, verifiable in 30 seconds:
Charge agents per proof with x402 →