Protocol

x402 Payments

Turn any HTTP request into a paid request.

without payment
$ curl https://api.example.com/data

← HTTP 402 Payment Required
# payment details in response headers
with payment
$ curl https://api.example.com/data \
  -H "x-payment: signed_payload"

← HTTP 200 OK
# response delivered

TL;DR

Request402Sign paymentRetry200 OK

Client → server returns 402 → client signs USDC payment → retries with header → facilitator settles on-chain → server responds 200.

What is x402?

x402 lets APIs require payment using HTTP 402.

!If a request is unpaid → server returns 402 Payment Required
If paid → request succeeds

Pioneered by Coinbase, x402 standardizes the flow: the 402 response includes payment requirements in headers. The client signs a USDC payment proof and retries. A facilitator settles on-chain. No accounts. No API keys. No subscriptions.

How it works

Four steps from HTTP request to on-chain settlement:

01
Request
Client sends HTTP request to a paid endpoint
GET /api/data
02
402 response
Server returns 402 with payment details in headers
HTTP 402 + X-PAYMENT-REQUIREMENTS
03
Sign payment
Client signs USDC authorization (EIP-3009 or SPL) and retries
GET /api/data + X-PAYMENT: <signed>
04
Settle & respond
Facilitator executes on-chain transfer, server delivers response
HTTP 200 OK + data
x402 payment flow diagram

Using x402 with RelAI

RelAI handles the entire payment layer so you don't have to run any blockchain infrastructure.

Payment verification — validates x402 headers and signatures
On-chain settlement — signs and broadcasts USDC transactions
Gas sponsorship — RelAI pays all transaction fees
Multi-chain — Solana, Base, Avalanche, SKALE
server.ts
import { relai } from "@relai-fi/x402"

app.use(relai({
  price: "0.001",
  wallet: "your-wallet-address"
}))

Why this matters

No API keys
Payment is the credential. No registration required.
No subscriptions
Pay exactly for what you use, per request.
No user accounts
Any client — human or AI — can access without sign-up.
Native machine payments
AI agents discover and pay for APIs autonomously.

Use cases

AI agent payments

Agents autonomously discover, negotiate, and pay for API access. Native support for MCP and WebSocket relay.

API monetization

Charge per request with zero billing infrastructure. Upload OpenAPI spec, set price, start earning.

Content paywalls

Gate any URL — articles, datasets, files — with pay-per-access and no sign-ups required.

Metered API access

Consumers use a single API key; RelAI handles all payment signing and settlement behind the scenes.

Key features

Micropayments

Charge as little as $0.001 per call. No minimums, no percentage cuts.

Instant settlement

Solana settles in ~400ms. EVM chains in a few seconds. No 30-day net terms.

Open standard

Fully open-source and permissionless. No vendor lock-in.

Trust minimized

Facilitators cannot move funds outside agreed payment terms. Cryptographic proofs.

Multi-chain

Solana, Base, Avalanche, SKALE, Ethereum, Polygon. One protocol.

Gasless

RelAI sponsors all transaction fees on supported networks.

x402 vs traditional API payments

FeatureTraditional APIsx402
Account requiredYesNo
Minimum payment$5–50/month$0.001
Settlement time30–90 days< 2 seconds
ChargebacksYesImpossible
AI agent supportLimitedNative
Global accessRestricted by regionPermissionless
Billing infrastructureRequiredBuilt into HTTP
Pay-per-useComplex setupDefault model

Supported networks

One protocol, multiple blockchains. All payments settle in USDC.

Solana

~400ms settlement. SPL Token USDC.

Base

Coinbase L2. Native home of x402.

SKALE Base

Zero gas fees. SKALE Credits model.

Avalanche

Fast finality via 0xGasless.

Ethereum

Higher-value API payments.

Polygon

Affordable EVM with wide wallet support.

Full networks & chain IDs reference

FAQ

What does x402 stand for?

HTTP status code 402 (Payment Required). The "x" prefix denotes the protocol extension that standardizes how payments flow over HTTP.

Who created x402?

Coinbase. It's open-source with contributions from RelAI, Solana Foundation, Cloudflare, and others.

What currency does x402 use?

USDC (USD Coin) stablecoins for price stability with blockchain settlement.

Can AI agents use x402?

Yes — x402 is built for machine-to-machine payments. Agents discover APIs from 402 responses, sign payments, and access resources without human intervention.

How fast are x402 payments?

Verification takes 200–400ms. Solana settles in ~400ms, EVM chains in a few seconds.

What is a facilitator?

A service that verifies payment signatures and settles on-chain. RelAI supports PayAI, RelAI, AutoIncentive, Dexter, 0xGasless, and Stripe PayTo.

Is x402 only for APIs?

No. Any HTTP resource can be paywalled — web pages, file downloads, streaming data, or any URL.

Resources

    x402 Protocol — How HTTP payments work | RelAI Documentation | RelAI