x402 Paid APIs for AI Agents
The x402 protocol turns HTTP 402 into programmable micropayments for AI agents. Here is why it matters and how to think about it.
The r/BASE community has been buzzing about x402 for months. In March 2026, the protocol crossed 119 million transactions. The premise is simple and a little revolutionary: HTTP 402 (Payment Required) was an unused status code for 35 years, and x402 finally gives it a meaning that makes sense for AI agents.
What x402 Actually Is
When your agent calls an x402-enabled API without credentials, the server returns HTTP 402 with a payment challenge (amount, currency, destination wallet). The client library signs a micropayment (typically USDC on Base) and retries with the payment header. The server verifies on-chain, returns the response, and everyone moves on.
The whole handshake takes about 200-400ms. No accounts, no API keys, no minimum commitment, no subscription renewals. Every call is priced independently.
Why This Matters for Agents
Autonomous agents are the perfect workload for pay-per-call billing. A research agent might need 3 Google searches, 2 Reddit lookups, and a YouTube transcript to answer a question. With prepaid credits, you pay for capacity you might not use. With x402, you pay for exactly what happens.
Three reasons this pattern is taking off:
- No vendor lock-in: the agent can switch between x402-compatible APIs at runtime based on price or availability.
- No pre-funding: a single funded wallet covers every x402 API the agent ever uses.
- Pay-per-agent-session: downstream apps can pass the cost of API calls to end-users without signing them up for API keys.
Wiring Up x402 in Python
The x402-python client handles the payment handshake. For Scavio's x402 endpoint:
from x402 import Client
import os
client = Client(
private_key=os.environ['X402_WALLET_KEY'],
network='base'
)
response = client.post(
'https://api.scavio.dev/x402/v1/search',
json={'query': 'AI agents 2026'}
)
print('Results:', len(response.json()['organic_results']))
print('Paid:', response.headers['x-402-amount'], 'USDC')x402 vs Prepaid Credits: When to Use Which
x402 is the right call when:
- Your agent is autonomous and usage is unpredictable
- You are building a consumer product that passes API costs to users
- You want to switch between APIs at runtime
- You want audit-ready per-call payment receipts
Prepaid credits (like Scavio's $30/mo plan) are still the right call when:
- You know your volume roughly in advance
- Your team has no crypto wallet infrastructure
- You want flat monthly billing for finance
The Sleeper Feature: Agent-Initiated Bounties
x402 supports reverse flows too. An agent can post an x402-signed task ("find 10 LinkedIn profiles matching this persona, willing to pay $0.50 per result") and any worker can fulfill it. This pattern is early, but it is where the agent economy is heading: agents hiring other agents, paying per completed task, with cryptographic receipts.
Scavio supports both x402 and credit-based billing so you can pick the pattern that fits your agent. Read the x402 docs to get started.