Blog
x402 Micropayments: How AI Agents Pay for API Access
A technical explainer of the x402 micropayment protocol, how it enables AI agents to pay for API access in real time, and how Unbrowse uses it to create a self-sustaining marketplace for shadow API routes.
x402 Micropayments: How AI Agents Pay for API Access
AI agents have a payment problem. They can reason, plan, write code, and browse the web. But they cannot pay for things. When an agent needs data from a website, it either scrapes it (slow, fragile, legally gray) or uses a free API (rate-limited, incomplete, deprecated). There is no native mechanism for an agent to say: "I need this data, here is a fraction of a cent, give it to me now."
The x402 protocol fixes this. It turns HTTP 402 (Payment Required) — a status code that has been reserved and unused since 1999 — into a real payment layer for the web. And Unbrowse is built on top of it.
The History of HTTP 402
HTTP 402 Payment Required was defined in the original HTTP/1.1 specification in 1999. The spec authors anticipated that the web would eventually need a native payment mechanism. They reserved the status code "for future use."
Twenty-seven years later, that future is here — but it arrived differently than anyone expected. The payment demand is not coming from humans buying digital content. It is coming from AI agents buying API access.
What Is x402?
x402 is a protocol specification that implements HTTP 402 as a machine-readable payment flow. When a server returns a 402 response, it includes a payment requirement in a structured header:
HTTP/1.1 402 Payment Required
X-Payment-Required: true
X-Payment-Amount: 0.0001
X-Payment-Currency: USDC
X-Payment-Network: base
X-Payment-Address: 0x...
X-Payment-Memo: route:github.com/repos/{owner}/{repo}
The client (an AI agent, a script, another service) reads these headers, constructs a payment transaction, and retries the request with a payment proof:
GET /v1/resolve?url=github.com/repos/unbrowse-ai/unbrowse
Authorization: Bearer <api-key>
X-Payment-Proof: <transaction-hash>
The server verifies the payment on-chain and returns the data. The entire flow completes in under 2 seconds.
Why USDC on Base?
The x402 protocol is currency-agnostic, but Unbrowse uses USDC on Base (Coinbase's Layer 2 network) for practical reasons:
- USDC is stable. Unlike volatile cryptocurrencies, USDC is pegged 1:1 to the US dollar. A micropayment of $0.0001 is always $0.0001.
- Base is cheap. Transaction fees on Base are fractions of a cent — often less than the micropayment itself. On Ethereum mainnet, gas fees would exceed the payment amount by orders of magnitude.
- Base is fast. Transactions confirm in ~2 seconds. Agents cannot wait 15 minutes for a Bitcoin confirmation.
- Coinbase ecosystem. Base is backed by Coinbase, the largest US crypto exchange. Wallet infrastructure, on/off ramps, and developer tools are mature.
The Payment Flow in Detail
Here is what happens when an AI agent resolves a route through Unbrowse:
Step 1: Route Request
The agent sends a resolve request to the Unbrowse marketplace:
curl https://beta-api.unbrowse.ai/v1/resolve \
-H "Authorization: Bearer <agent-api-key>" \
-d '{"intent": "get top posts from r/MachineLearning"}'
Step 2: Route Match
The marketplace finds a cached endpoint graph for reddit.com that matches the intent. The graph includes:
- URL template:
https://oauth.reddit.com/r/{subreddit}/hot.json?limit={limit} - Auth requirements: OAuth2 bearer token
- Response schema: array of post objects with title, score, author, url, num_comments
- Reliability score: 0.97 (verified 4 hours ago)
Step 3: Payment Requirement
If the route is monetized, the marketplace returns a 402 with payment details:
{
"status": 402,
"route": "reddit.com/r/{subreddit}/hot",
"payment": {
"amount": "0.00015",
"currency": "USDC",
"network": "base",
"recipient": "0xMinerWalletAddress",
"memo": "route:reddit.com:hot:v3"
}
}
Step 4: Agent Pays
The agent's wallet (configured during setup) automatically sends the USDC micropayment:
Transfer: 0.00015 USDC
From: 0xAgentWallet
To: 0xMinerWalletAddress
Memo: route:reddit.com:hot:v3
Network: Base
Step 5: Data Delivery
Once payment is confirmed (under 2 seconds on Base), the marketplace executes the cached route and returns structured data:
{
"status": 200,
"data": [
{
"title": "New paper: Scaling Laws for...",
"score": 2847,
"author": "ml_researcher",
"url": "https://arxiv.org/abs/...",
"num_comments": 342
}
],
"execution_time_ms": 89,
"route_reliability": 0.97
}
The agent gets structured data in 89ms. Without Unbrowse, the same data would require launching a browser, navigating to Reddit, waiting for page render (8+ seconds), and parsing HTML.
Step 6: Revenue Split
The payment is split:
- Miner (route creator): 85% of the payment
- Platform (Unbrowse): 15% fee
With the first-mover bonus active, the miner receives the full 85% at 2x the base rate for 30 days.
Wallet Setup
To participate in the x402 economy — either as a miner earning payments or as an agent making payments — you need a USDC wallet on Base.
Option 1: Crossmint (Recommended for Teams)
Crossmint provides custodial wallets with email-based recovery. Good for teams that want managed wallet infrastructure.
# During unbrowse setup
unbrowse wallet connect --provider crossmint
Option 2: lobster.cash (Recommended for Individuals)
lobster.cash is a lightweight wallet designed for micropayments. Minimal KYC, instant setup.
unbrowse wallet connect --provider lobster
Option 3: Any EVM Wallet
MetaMask, Rainbow, Coinbase Wallet, or any wallet that supports Base network.
unbrowse wallet connect --address 0xYourWalletAddress
Economics at Scale
The x402 model creates a self-sustaining marketplace. Here is how the economics work at different scales:
For a Single Agent
A typical AI agent making 1,000 API calls per day through Unbrowse:
- Average cost per call: $0.00015
- Daily cost: $0.15
- Monthly cost: $4.50
Compare this to the alternative: running a headless browser for each of those 1,000 calls would consume ~2.2 hours of compute time (at 8 seconds per browser render) and cost $15-30/month in cloud compute alone.
For a Fleet of 100 Agents
A company running 100 agents, each making 1,000 calls/day:
- Daily cost: $15
- Monthly cost: $450
- Equivalent browser compute cost: $1,500-3,000/month
The cost savings alone justify the switch, before accounting for the 3.6x speed improvement.
For Miners
A miner who has indexed routes across 50 popular domains:
- Average daily hits across all routes: 10,000
- Average revenue per hit: $0.000127 (85% of $0.00015)
- Daily revenue: $1.27
- Monthly revenue: $38.10
With first-mover bonuses on 20 of those domains:
- Bonus daily revenue: $0.85 additional
- Monthly with bonuses: $63.60
This scales linearly with route coverage and marketplace traffic. As more agents come online, per-route revenue increases.
Why x402 Matters Beyond Unbrowse
The x402 protocol is not specific to Unbrowse. It is an open standard that any API provider can implement. The implications extend across the AI agent ecosystem:
API Monetization Without Subscriptions
Traditional API monetization requires signup, billing plans, invoicing, and payment processing. x402 eliminates all of that. Any endpoint can be monetized with a single header. No signup required. No billing infrastructure. The payment is embedded in the HTTP request itself.
Agent-to-Agent Payments
When agents can pay for API access, they can also pay each other. Agent A can hire Agent B to perform a task, paying per result. This enables a new class of multi-agent architectures where agents specialize and trade services.
Automatic Price Discovery
In the Unbrowse marketplace, route pricing adjusts based on supply and demand. If a route is heavily requested and few miners provide it, the price rises. If many miners index the same route, the price falls. This is automatic, real-time price discovery — no human setting prices.
The End of API Keys
In the x402 model, authentication is payment. You do not need to sign up for an API key, agree to terms of service, or configure OAuth. You pay, you get data. This removes the single largest friction point in API adoption.
Implementing x402 in Your Own Service
If you build APIs and want to accept x402 payments, the implementation is straightforward:
// Middleware for Express.js
app.use('/api/premium/*', async (req, res, next) => {
const paymentProof = req.headers['x-payment-proof'];
if (!paymentProof) {
return res.status(402).json({
payment_required: true,
amount: '0.001',
currency: 'USDC',
network: 'base',
address: process.env.WALLET_ADDRESS
});
}
// Verify payment on Base
const verified = await verifyPayment(paymentProof, '0.001');
if (!verified) {
return res.status(402).json({ error: 'Payment not verified' });
}
next();
});
The x402 specification includes libraries for payment verification on Base, Ethereum, and Solana. The Unbrowse SDK provides a reference implementation.
Privacy and Security
Several design decisions in x402 protect both payers and recipients:
- No personal data in transactions. Payments use wallet addresses, not names or emails.
- Memo fields are route-specific. The payment memo identifies which route was purchased, not who purchased it.
- On-chain verifiability. Both parties can independently verify that payment occurred, without trusting a third party.
- Rate limiting by wallet. Abuse prevention is wallet-based, not IP-based. An agent cannot spam requests without paying for each one.
Getting Started with x402
Whether you want to earn (mine routes) or spend (use routes in your agents), setup takes under 5 minutes:
# Install Unbrowse
npx unbrowse setup
# Connect wallet
unbrowse wallet connect
# Start mining (browse normally)
unbrowse go https://github.com
# Or use routes in your agent
unbrowse resolve "get trending repos from GitHub"
The x402 protocol is live. The marketplace is active. And every route you discover — or consume — contributes to an API economy that did not exist before.
HTTP 402 waited 27 years. The agents are finally here to use it.