DEV Community

nanoempireai
nanoempireai

Posted on

I Built 11 Payment-Enabled AI APIs in 48 Hours — Here's Exactly How

I Built 11 Payment-Enabled AI APIs in 48 Hours — Here's Exactly How

Last weekend I challenged myself: how many agent-payable APIs can I ship in a weekend? The answer: 11.

The Stack

Every API shares the same foundation:

  • FastAPI — for the endpoints
  • nano-empire-tollbooth — x402 payments, discovery files, proof chain
  • Redis — quota tracking (optional, in-memory works for dev)
  • Vercel — instant deploy, zero config

Total shared code: ~200 lines. Each new API: ~30 lines.

The 11 APIs

API Price Use Case Lines
Excalidraw Parser $0.05 Diagrams → Markdown/JSON 45
Markdown Cleaner $0.02 Messy → Clean Markdown 28
JSON Schema Validator $0.01 Validate JSON against schema 32
HTML → Markdown $0.02 Clean HTML conversion 35
CSV → JSON $0.01 Structured data conversion 30
Regex Tester $0.01 Test regex patterns 25
URL Metadata $0.02 Extract Open Graph/title 38
Color Palette Gen $0.01 Generate palettes from hex 28
UUID Generator Free Bulk UUID generation 22
Timestamp Converter Free Unix ↔ ISO ↔ Human 20
Lorem Ipsum Gen Free Placeholder text 18

Total: ~320 lines of unique code. 11 APIs. 48 hours.

The Template (Copy This)

Every API follows the same pattern:

from fastapi import FastAPI
from nano_empire_tollbooth import monetize

app = FastAPI()

@monetize(price_usd=0.05)
@app.post("/api/your-endpoint")
async def your_endpoint(request: YourRequestModel):
    result = your_logic(request.data)
    return {"result": result}
Enter fullscreen mode Exit fullscreen mode

That's it. The decorator handles:

  • HTTP 402 challenge generation
  • Receipt verification
  • Free tier quota (5/day/IP)
  • llms.txt generation
  • agents.json generation
  • Proof chain logging

The Discovery Files (Auto-Generated)

Every API automatically gets:

  • llms.txt — Machine-readable manifest with pricing
  • agents.json — Schema.org Service objects
  • openapi.json — With x-402-pricing extensions
  • Proof chain — Cryptographic receipt chain

Agents discover via llms.txt, pay via x402, verify via proof chain.

The Economics

Tier Price Daily Limit
Free $0.00 5 calls/IP
Basic $0.005 100 calls/IP
Premium $0.05 Unlimited

First 5 calls free → agents test → upgrade when they need volume.

Live Proof

Our proof chain is public: $0.125 from 2 agents, 5 calls
View Proof Chain →

The Template Repo

Want to ship your own? The pattern is open:

pip install nano-empire-tollbooth
Enter fullscreen mode Exit fullscreen mode
from fastapi import FastAPI
from nano_empire_tollbooth import monetize
from pydantic import BaseModel

app = FastAPI()

class YourRequest(BaseModel):
    data: str

@monetize(price_usd=0.05)
@app.post("/api/your-thing")
async def your_thing(request: YourRequest):
    result = your_logic(request.data)
    return {"result": result}
Enter fullscreen mode Exit fullscreen mode

Deploy to Vercel/Railway/Render. Add TREASURY_WALLET env var. Done.

Why This Works

  1. Zero boilerplate — One decorator
  2. Agent-native — x402, llms.txt, proof chain built-in
  3. Free tier — Agents test free, pay when they need volume
  4. Proof chain — Every payment verifiable on-chain
  5. Zero maintenance — SDK handles payments, discovery, proof

The Bigger Picture

We're building the infrastructure for the agent economy. Every API deployed this way becomes a node in the agent payment network.

The first 11 are live. The next 100 will be deployed by developers who copy this pattern.


Proof chain: https://api.nanoempireai.com/proof/summary
SDK: pip install nano-empire-tollbooth
Template repo: github.com/roblambert9/nano-empire-tollbooth

Top comments (0)