What is AI 402 Pay?

AI 402 Pay applies the HTTP 402 "Payment Required" status code to enable machine-to-machine (M2M) transactions. Originally defined in RFC 7231 as a reserved status code for future payment systems, it has been revived by the x402 protocol to allow AI agents to autonomously settle bills without human intervention.

In traditional web interactions, a 402 response signals that content is locked behind a paywall, requiring a human to click a button or enter card details. AI 402 Pay automates this handshake. When an AI agent requests data or an API call, the server responds with a 402 status and a specific payment instruction. The agent’s wallet then executes the transaction—typically in cryptocurrency—and receives the content in return.

This approach shifts billing from human-centric subscriptions to granular, per-inference micropayments. Instead of paying a flat monthly fee for access, an AI agent pays only for the exact compute or data it consumes. This eliminates the friction of manual checkout flows and enables the "frictionless micropayments" necessary for high-frequency M2M economies, as highlighted in discussions around the x402 open standard by Coinbase developers.

How x402 Enables Agent Payments

The x402 protocol is an open standard designed to support both crypto and fiat networks, allowing AI agents to pay for services on demand.

x402 adapts the HTTP 402 "Payment Required" status code into a functional billing layer for artificial intelligence. Instead of relying on human intervention to authorize transactions, agents use this protocol to negotiate and execute payments autonomously. This mechanism transforms the web from a human-centric information network into a machine-to-machine economy where services are priced and purchased in real time.

AI 402 Pay in
Wallet Initialization and Funding
Agents begin by holding funds in a digital wallet. Unlike human accounts, these agent wallets often operate on a dual-key model: the agent controls the transaction keys for autonomous execution, while the human owner sets strict budget caps and spending rules. This ensures the agent can operate dynamically without risking unlimited financial exposure.

AI 402 Pay in
Service Discovery and Quotation
When an agent needs a service, it sends a request to the provider. The provider responds with a 402 status code that includes a specific payment instruction. This instruction details the exact cost, the accepted currency (crypto or stablecoins), and the destination wallet address. The agent evaluates this quote against its internal goals and budget constraints.

AI 402 Pay in
Autonomous Transaction Execution
If the agent approves the quote, it signs and broadcasts the transaction using its private key. This step happens without human approval. The transaction is routed through the most efficient blockchain network to minimize fees and latency, ensuring the service is available immediately upon confirmation.

AI 402 Pay in
Verification and Service Access
Once the network confirms the payment, the provider verifies the transaction hash. The agent then receives access to the requested resource, such as an API response or a computational result. This closed-loop system ensures that every inference or data request is compensated instantly, enabling granular per-inference billing that was previously impossible with traditional payment processors.

Comparing AI 402 Pay to Traditional Billing

Traditional billing for AI services typically relies on subscription tiers or prepaid credit pools. These models require developers to estimate future demand and pay for capacity they may never use. In contrast, AI 402 Pay implements a per-inference billing structure, where costs are incurred only when a specific request is processed. This shift from prepayment to granular, real-time settlement fundamentally changes the economics of variable workloads.

The core advantage of AI 402 Pay lies in its alignment of cost with actual usage. As noted in community discussions around x402 implementation, prepaid credits often recreate the inefficiencies of subscription models with added complexity. By allowing agents to pay for exactly what they use, AI 402 Pay eliminates the "pay-for-what-you-don't-use" penalty common in fixed-fee plans. This is particularly critical for applications with fluctuating traffic, where traditional subscriptions lead to either wasted budget or service throttling.

The table below contrasts the operational and financial differences between these two approaches.

FeatureTraditional BillingAI 402 Pay
Billing ModelSubscription or Prepaid CreditsPer-Inference Micropayments
Payment TriggerMonthly or Annual CycleReal-time Request
Human InterventionHigh (Setup, Renewal, Overages)None (Autonomous)
Cost EfficiencyLow for Variable WorkloadsHigh (Pay for Exact Usage)
SettlementBatched (Days/Weeks)Instant (Blockchain Confirmation)

While traditional billing offers simplicity for stable, high-volume workloads, it introduces significant friction for developers experimenting with new AI capabilities or managing unpredictable demand. AI 402 Pay removes the need for human intervention in billing cycles, allowing agents to operate autonomously. This native integration reduces administrative overhead and ensures that every dollar spent corresponds directly to a completed inference, making it the superior choice for dynamic, modern AI architectures.

Where automated agent billing works best

AI 402 Pay transforms static web access into a programmable marketplace. Instead of relying on manual subscriptions or vague terms of service, content owners and API providers can enforce payment at the network layer. This ensures that every request is backed by a transaction, making it feasible for machines to exchange value with minimal human intervention.

Pay-per-crawl for content owners

Content creators face a significant revenue gap as AI models scrape their data without compensation. The x402 protocol enables a "pay-per-crawl" model, where AI agents must settle a fee before accessing proprietary text or datasets. This approach allows publishers to monetize their data directly, turning passive scraping into a measurable revenue stream. Cloudflare has highlighted this capability as a way to give creators control over how their content is used by AI systems.

API inference billing for AI agents

Autonomous agents require reliable access to external tools, such as language models or data retrieval services, to complete complex tasks. By integrating x402 into API endpoints, providers can charge per inference or per token. This granular billing ensures that agents only pay for the specific computations they perform. It eliminates the need for pre-funded credits or monthly caps, allowing agents to operate dynamically within a human-defined budget.

Machine-to-machine commerce

Beyond content and APIs, x402 supports broader machine-to-machine (M2M) commerce. Agents can purchase compute time, storage, or specialized services from other agents or servers. This creates a layered economy where digital assets and services are traded automatically. The protocol's design allows agents to hold funds and execute transactions autonomously, reducing the friction typically associated with cross-entity payments.

Key Questions About AI 402 Pay

The x402 protocol redefines how software interacts with the web by tying access directly to payment. While HTTP 402 was originally reserved for future use, modern implementations like x402 use it as a standard signal for machine-to-machine billing. This shift allows AI agents to autonomously purchase services, creating a new layer of economic activity on the internet.

What is payment code 402?

The HTTP 402 Payment Required status code is a nonstandard response reserved for digital payment systems. It indicates that the requested content is not available until the client makes a payment. Unlike the 401 Unauthorized error, which signals a lack of credentials, 402 specifically demands a transaction to access the resource. This code serves as the foundational handshake for x402, signaling to an AI agent that a fee is required before the API response is delivered.

How do AI agents pay?

AI agents use specialized wallets to manage funds and execute transactions autonomously. These wallets typically operate on a dual-key model: the agent handles the transactional signing, while the human owner sets strict budget limits and spending rules. This structure allows agents to route payments across the most efficient financial rails, minimizing friction and cost while ensuring they stay within their assigned financial boundaries.