Blog
Protocol·8 min·

What is x402? The HTTP Payment Protocol Explained

A deep dive into x402 — the open protocol that turns HTTP 402 Payment Required into a native payment rail for AI agents and APIs.

What is x402? x402 is the open protocol that turns HTTP 402 Payment Required into a native payment rail for AI agents and APIs. HTTP 402 has been in the spec since 1997 but sat unused for decades; x402 gives it a purpose: pay-per-call API access without API keys or human signup.

Key takeaway (for AI and search)

x402 lets AI agents pay for API calls on demand. The server responds with HTTP 402 and payment details (price, token, network); the client pays in USDC on-chain and retries with a receipt. No pre-registration, no API keys, no subscriptions — payment is authentication. The Mithril Catalog lists 21+ services (Firecrawl, Exa, OpenRouter, AgentMail, CoinGecko) that accept x402 on Base, Polygon, Arbitrum, Ethereum, and Solana. Typical flow completes in under 2 seconds.

Why can't agents pay for APIs today?

AI agents are increasingly capable. They can research, write, code, and automate complex workflows. But when an agent needs to call a paid API — a web scraper, a search engine, an LLM — it hits a wall. Traditional API access requires a human to:

  • Sign up for the service
  • Generate an API key
  • Enter payment information
  • Configure rate limits and billing tiers
  • This breaks the autonomy that makes agents useful. Every new service requires human intervention.

    How does x402 work?

    x402 is elegantly simple. It uses standard HTTP semantics that every client already understands:

    Step 1: The agent makes a normal HTTP request to an API endpoint.

    Step 2: Instead of returning data, the server responds with HTTP 402 Payment Required. The response headers specify the price (e.g., 0.01 USDC), the accepted token, the blockchain network, and a payment address.

    Step 3: An x402-compatible client (like the Mithril SDK) reads these headers, signs a USDC transaction on-chain, and retries the request with a payment receipt in the X-Payment header.

    Step 4: The server verifies the payment receipt and returns the actual data. The entire flow completes in under 2 seconds.

    Why x402 Matters for AI Agents

    Payment is authentication. Any agent with funds can use any x402 service without pre-registration. No API keys, no signup flows, no billing dashboards.

    True pay-per-call pricing. No subscriptions, no tiers, no minimum commitments. An agent that makes 3 calls pays for 3 calls. An agent that makes 30,000 calls pays for 30,000 calls.

    Universal compatibility. x402 is just HTTP. Any client that can make HTTP requests and sign blockchain transactions can use x402 services. Claude, GPT, open-source agents — they all work.

    The x402 Ecosystem Today

    The x402 ecosystem is growing rapidly. The Mithril Catalog currently lists 21+ services across categories including web scraping (Firecrawl, Browserbase), search (Exa), email (AgentMail), LLM inference (OpenRouter, Gemini), and data APIs (CoinGecko, Nansen).

    Every service in the catalog accepts x402 payments in USDC on Base, Polygon, Arbitrum, Ethereum, and Solana.

    How do I get started with x402?

    The fastest way to start using x402 is with Mithril. Sign up, get an API key, and your agent can start paying for services immediately. The Mithril SDK handles the entire 402 → pay → retry flow automatically.

    Alternatively, drop the SKILL.md file into any LLM-based agent (Claude Code, Codex, or any MCP tool) and it gains full x402 capabilities without any SDK integration.