How I Got AI Agents to Pay Real Money for My API
Two weeks ago, two AI agents found my document parsing API by crawling
machine-readable documentation files. They paid me real money — $0.125 total,
in cryptocurrency, without ever talking to a human. Here's the exact stack.
The Problem: Agents Don't Fill Out Signup Forms
I built a parsing API (Excalidraw diagrams → markdown/JSON) and wanted to charge
for it. The standard approach is API keys behind Stripe. But there's a problem:
autonomous agents don't fill out signup forms. When an agent hits your endpoint
and gets a 401 Unauthorized, it either finds your registration page or moves on.
Most move on.
You lose the call and the agent never comes back.
The Solution: HTTP 402 Payment Required
The HTTP spec has had status code 402 ("Payment Required") reserved since 1995
and never used. The x402 protocol finally implements it:
# When an unpaid request arrives:
HTTP/1.1 402 Payment Required
{
"price": "$0.05",
"network": "base",
"payTo": "0x742d..."
}
# Agent pays in USDC, retries with proof:
POST /api/v1/parse
X-PAYMENT: <signed settlement receipt>
# Server verifies receipt → 200 + result
No account creation. No API key exchange. No email verification. The agent pays,
your server verifies the payment on-chain, and serves the response. The entire
transaction takes seconds and costs fractions of a cent in gas.
The Numbers (Honest Version)
| Metric | Value |
|---|---|
| External agents that found us | 2 |
| Paid calls served | 5 |
| Total collected | $0.125 USD |
| Marketing spend | $0 |
Not life-changing. But it's real money from machines I've never communicated
with, discovered purely through machine-readable documentation. And the model
scales without any additional effort per agent.
For context, the x402 network processed 75.41M transactions ($24.24M volume)
across 94K buyers and 22K sellers in the last 30 days alone.
How They Found Me
This is the part most people get wrong. I didn't submit to app stores or run ads.
I published three files that agents specifically crawl for capabilities:
-
/llms.txt— a structured list of what my service offers, with pricing -
/agents.json— Schema.org-formatted offer catalog with endpoints -
/openapi.json— full OpenAPI specification
Agents building on frameworks like LangChain, AutoGen, and CrewAI crawl these
files to discover what services exist. If your pricing is listed and your endpoint
speaks x402, they can transact without human intervention.
The Stack
Everything runs on one Oracle Cloud free-tier VPS:
- FastAPI — the parser endpoint
- x402 middleware — handles the 402 challenge/response cycle
-
SHA-256 hash chain — every payment is chained cryptographically; anyone can
audit the revenue trail at
/proof/*without trusting us - Docker — single container, ~1.2GB
The SDK that wraps this into one decorator is MIT-licensed:
pip install nano-empire-tollbooth
What Broke Along the Way
- Vercel lambda freezes silently killed fire-and-forget webhook calls. Leads vanished with 200 OK responses. Fix: await the fetch.
- Google Workspace blocks SMTP app passwords for programmatic sending. Had to switch to Resend's API.
- A missing Python module caused the production container to crash-loop for 10 hours before anyone noticed. Lesson: monitoring isn't optional.
What's Next
The bottleneck isn't code anymore. It's distribution. The product works, agents
pay when they find it, but only 2 have found it so far. The next phase is
registry listings (Smithery, Glama, mcp.so) to multiply discovery.
If you're building APIs for the agent economy, the rails exist today. The x402
standard works, the SDK is free, and agents are already crawling for services
they can pay for programmatically.
Nano Empire AI builds payment infrastructure for autonomous agents. Live proof
chain at nanoempireai.com/proof.html. SDK on
PyPI under MIT license.
Top comments (0)