What is AI 402 Pay

AI 402 Pay is a payment protocol that allows artificial intelligence agents to pay for digital services directly. It is built on the x402 standard, which revives a forgotten part of the HTTP protocol history to solve a modern problem: how machines should pay each other.

The system works by embedding a payment requirement directly into the HTTP response. When an AI agent requests data or a service, the server responds with a 402 status code. This code includes a proof of payment—usually a cryptocurrency transaction—that the agent must submit to access the requested content.

This approach removes the need for traditional subscription models or high-fee payment processors. Instead, it enables instant, machine-to-machine transactions using cryptocurrency. For small businesses, this means they can offer pay-per-use services that are automated, secure, and accessible to AI-driven workflows.

  • Autonomous Transactions: AI agents handle the entire payment process without human intervention.
  • Micropayment Ready: The protocol is designed for small, frequent transactions that are often too expensive for traditional credit card networks.
  • Open Standard: x402 is an open protocol, allowing any developer to build compatible tools and services.

By using AI 402 Pay, businesses can tap into the emerging agent economy, where digital services are bought and sold automatically by software.

Why traditional gateways fail AI agents

AI 402 Pay solves the structural mismatch between how small businesses operate and how legacy payment processors charge. Traditional gateways like Stripe or PayPal were built for human shoppers buying physical goods. They are not built for autonomous agents buying digital content.

The primary friction point is the subscription model. AI agents do not think in monthly cycles; they think in discrete requests. As noted in community discussions, forcing agents into prepaid credit or subscription tiers "just recreates the subscription model with extra steps." This creates unnecessary complexity for what should be a simple pay-per-use interaction.

The second friction point is the fee structure. Legacy processors charge fixed per-transaction fees (often $0.30) plus a percentage. For the median AI agent transaction, which research shows falls between $0.01 and $0.10, these fixed fees make the transaction economically impossible. You cannot profitably process a one-cent payment when the processor takes thirty cents.

AI 402 Pay removes these barriers by enabling microtransactions that settle instantly with minimal overhead. It allows small businesses to monetize granular data, API calls, or content snippets that were previously too small to process.

FeatureTraditional GatewaysAI 402 Pay
Transaction Minimum$0.50 - $1.00$0.01
Fee Structure$0.30 + 2.9% per txnNear-zero gas fees
Billing ModelSubscription or InvoicePay-per-use
Settlement2-7 daysNear-instant
Agent CompatibilityPoor (requires human UI)Native (HTTP 402)

Set up your x402 API for AI 402 Pay

Getting AI 402 Pay working on your backend requires connecting three pieces: a wallet to hold funds, middleware to handle requests, and a facilitator to process the transactions. This setup allows your API to accept micropayments directly from AI agents without manual intervention.

1
Create a dedicated server wallet

You need a digital wallet to manage the funds for your AI 402 Pay service. Use a secure, server-side wallet solution that supports EIP-7702, which allows for gasless transactions. This wallet will act as the primary account for receiving payments from AI agents. Keep your private keys secure and never expose them in your frontend code or public repositories.

2
Install x402 middleware

Add the x402 middleware library to your backend framework. Whether you use Hono, Next.js, or Express, there is a compatible package that intercepts API calls. The middleware checks for the x402 payment header in incoming requests. If the payment is valid, the request proceeds; if not, it returns a 402 Payment Required response.

3
Configure the facilitator service

The facilitator handles the heavy lifting of verifying and submitting payments on-chain. Connect your server wallet to a facilitator service like the one provided by Thirdweb. This service uses your wallet to submit transactions gaslessly, ensuring that your API doesn’t get bogged down by network fees or transaction delays. Configure the facilitator endpoint in your middleware settings.

4
Test with a mock agent

Before going live, simulate an AI agent making a request. Use a simple script to send a request with a valid x402 payment header to your API. Verify that the middleware processes the payment correctly and that the facilitator submits the transaction. This step ensures your AI 402 Pay integration is robust and ready for real-world traffic.

Costs and Benefits for Small Businesses

AI 402 Pay changes the math for small businesses by removing per-transaction fees. Traditional payment processors charge fixed costs that make tiny sales unprofitable. AI 402 Pay eliminates these fees, allowing businesses to monetize micro-interactions that were previously ignored.

The financial impact is most visible in the transaction volume. According to research, the median payment by agents using x402 is between $0.01 and $0.10. This range is where traditional fees often exceed the transaction value. Without these costs, small businesses can offer AI services at a fraction of the price while maintaining healthy margins.

This model supports high-volume, low-value exchanges. Businesses can sell access to AI tools, data, or content in small increments. The absence of fixed fees means every transaction adds to the bottom line. This scalability is a significant benefit for companies offering AI services to a broad audience.

76%
of agent transactions are between $0.01 and $0.10

Common Questions About x402

What is AI in payments?

AI in payments uses machine learning and intelligent automation to handle how financial transactions are processed, secured, and reconciled. Instead of manual checks, AI applies predictive analytics across the entire payment lifecycle. This includes pre-payment fraud screening and post-payment cash application, ensuring that small business micropayments are both secure and efficient.

What is an x402 facilitator?

An x402 facilitator is a service that verifies and submits x402 payments on behalf of your application. It uses your own server wallet and leverages EIP-7702 to submit transactions gaslessly. The thirdweb facilitator is compatible with any x402 backend and middleware libraries like x402-hono or x402-next, making integration straightforward for developers.