DEV Community

nanoempireai
nanoempireai

Posted on

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
Enter fullscreen mode Exit fullscreen mode

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 two files:

  1. llms.txt - tells agents what my API does and what it costs
  2. agents.json - machine-readable manifest for auto-discovery + payment

Agents crawl the web looking for these files. Two found mine, read the price, paid the toll, and got their result. No human in the loop.

The Stack

  • Parser: Excalidraw JSON -> markdown/JSON (dual format, dual-format parser)
  • Gateway: FastAPI + x402 middleware (Tollbooth SDK)
  • Payments: x402 protocol (HTTP 402 + Solana USDC)
  • Proof Chain: SHA-256 ledger + Ed25519 signatures (tamper-evident)
  • Frontend: Static HTML/JS (proof.html, audit.html)

The Code

# Tollbooth middleware (nano-empire-tollbooth PyPI)
from nano_empire_tollbooth import monetize

@monetize(price_usd=0.05)
async def parse_diagram(source: str):
    return parse_excalidraw(source)

# Agent hits endpoint -> 402 with price -> pays -> retry with receipt -> 200 OK
Enter fullscreen mode Exit fullscreen mode

What's Next

  • Open sourcing the Tollbooth SDK (MIT)
  • Adding more parser formats (Mermaid, PlantUML)
  • Revenue certification for agents (the $199 AgentAudit service)

If you're building APIs for agents, the payment layer is the missing piece. x402 makes it trivial to monetize without the SaaS overhead.

Full repo: https://github.com/roblambert9/nano-empire-tollbooth
Live proof chain: https://nanoempireai.com/proof.html

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.