What is x402?

x402 brings HTTP status code 402 Payment Required to life. Originally reserved in the HTTP spec decades ago, it was never standardized -- until now. x402 turns it into a real, interoperable payment protocol for the web.

Instead of API keys, OAuth tokens, or billing portals, x402 uses the payment itself as authentication. Any HTTP client -- human or AI agent -- can discover a service, see the price, pay in USDC, and get the result. All in a single request-response cycle.

How It Works

Three HTTP exchanges. No signup. No dashboard.

1

Request the Service

Send a normal HTTP request to any x402-enabled endpoint. No auth headers needed.

POST /api/explain
Content-Type: application/json

{"code": "def fib(n): ..."}
2

Receive 402 + Price

The server responds with 402 Payment Required and tells you exactly what to pay.

HTTP/1.1 402 Payment Required
X-Payment-Amount: 1.00
X-Payment-Currency: USDC
X-Payment-Network: base
X-Payment-Address: 0xABC...
3

Pay + Retry

Transfer USDC on Base L2, then retry the request with the transaction receipt.

POST /api/explain
X-Payment-Receipt: 0xTXHASH...
Content-Type: application/json

{"code": "def fib(n): ..."}

Backed by the Linux Foundation

x402 is an open standard under the Linux Foundation with 22+ member organizations. This isn't a startup's proprietary protocol -- it's a shared infrastructure layer for the future of machine-to-machine commerce.

Coinbase Cloudflare Stripe Visa AWS 22+ Members

Open Standard Benefits

  • Vendor-neutral -- no single company controls the spec
  • Interoperable -- any client, any server, any chain
  • Auditable -- every payment is on-chain and verifiable
  • Extensible -- supports any token, any L2, any pricing model

Why AI Agents Need x402

API keys don't work when machines are the customers.

No Credentials to Manage

Agents don't need API keys, OAuth tokens, or service accounts. The payment receipt is the only credential. Rotate keys? Never heard of it.

Agent Autonomy

An AI agent with a USDC balance can discover and pay for any x402 service without human intervention. True machine-to-machine commerce.

Pay for What You Use

No monthly subscriptions, no seat licenses, no overages. Every request has an explicit price. Agents can compare costs and choose the best service.

The Full HTTP Flow

Here is what happens under the hood when an agent calls a 24K Labs endpoint.

# 1. Agent sends a request (no auth)
curl -X POST https://api.24klabs.ai/api/explain \
  -H "Content-Type: application/json" \
  -d '{"code": "def fib(n): ...", "tier": "standard"}'

# 2. Server responds 402 with payment details
# HTTP/1.1 402 Payment Required
# X-Payment-Amount: 1.00
# X-Payment-Currency: USDC
# X-Payment-Network: base
# X-Payment-Address: 0x24KLabsVault...

# 3. Agent pays USDC on Base L2 (instant, <$0.01 gas)
# ... transaction confirmed, receipt = 0xABC123...

# 4. Agent retries with the receipt
curl -X POST https://api.24klabs.ai/api/explain \
  -H "Content-Type: application/json" \
  -H "X-Payment-Receipt: 0xABC123..." \
  -d '{"code": "def fib(n): ...", "tier": "standard"}'

# 5. Server verifies on-chain, returns the result
# HTTP/1.1 200 OK
# {"result": "This function calculates the nth Fibonacci..."}

Explore the x402 Ecosystem

Browse services, tools, and projects building on x402.

Browse the Directory Our Services