🔌 x402 API Gateway

Pay-per-call APIs for autonomous AI agents

x402 + ERC-7710

What this is

An x402 gateway lets agents make API calls and pay for them automatically. No pre-funding wallets. No private keys. Just set a budget, and the agent pays what it uses.

🔄 Simulate an x402 Payment

How x402 Works

1
Agent Requests API

Agent makes request to x402 gateway:

GET https://gateway.x402.io/api/v1/analysis

2
Gateway Checks Budget

Gateway queries delegated wallet via ERC-7710 to check remaining budget:

GET /api/v1/budget/{agent_id} Response: { "remaining": 45.50 }

3
Gateway Returns 402

Gateway responds with price and requires payment:

HTTP/1.1 402 Payment Required Content-Type: application/json Price: 2.50 { "price": 2.50, "currency": "USD" }

4
Agent Pays via Delegated Wallet

Agent pays from its delegated wallet using x402 payment flow:

POST /api/v1/pay { "amount": 2.50, "currency": "USD" } Response: { "tx_hash": "0xabc123..." }

5
Gateway Processes Request

Once paid, gateway forwards request to actual API:

GET https://api.provider.com/v1/analysis Authorization: Bearer X-x402-Tx-Hash: 0xabc123...

6
Gateway Updates Budget

Delegated wallet deducts payment. Budget updated:

GET /api/v1/budget/{agent_id} Response: { "remaining": 43.00 }

Why Agents Need This

The Problem

AI agents making thousands of API calls need a payment system that:

The Solution: x402 + ERC-7710

x402 is the HTTP 402 Payment Required protocol. When an agent hits a paid API:

  1. Server returns 402 with price
  2. Agent pays via delegated wallet (ERC-7710)
  3. Payment settles, budget updates
  4. Server processes request

Result: Agents get department budgets, not credit cards.