I Wired Up $0.02 Micropayments to an API Endpoint
I’ve been experimenting with x402 — a protocol for pay-per-call API pricing using on-chain micropayments.
The idea: instead of subscriptions or API keys tied to a billing account, you hit an endpoint and pay inline with the request. $0.02 per call. USDC on Base. No signup, no monthly seat, no “contact sales.”
Here’s what surprised me: the official SDK doesn’t work on Vercel serverless. The facilitator needs to initialize at startup, but Vercel’s serverless functions are cold on every invocation — no persistent startup phase. The SDK assumes a long-lived process.
So I implemented the protocol manually. It’s simpler than it sounds:
- If no payment header → return
402 Payment Requiredwith a JSON body: amount, asset (USDC), network (Base), recipient wallet - If payment header present → verify it, then serve the response
The tricky part is verification, but Base’s RPC is fast enough that latency isn’t a real issue.
I’m not sure yet which use case this actually serves best. My instinct is that API keys win for most developers — they’re familiar and billing is straightforward. But x402 gets interesting for autonomous agents: AI workflows that need to call external services without a human managing credentials or a billing account behind them. Pay-per-call with on-chain settlement is a natural fit for that.
Still early. I want to keep experimenting with x402 on a few different surfaces and see what sticks. The protocol itself is solid — the question is whether the use case is real enough that people actually reach for it.