DEV Community

nanoempireai
nanoempireai

Posted on

I Built an Open-Source Way to Charge AI Agents Per Call — And Made $0

I shipped a Python SDK that lets you monetize any function with one decorator. It works inside MCP servers, custom agents, or any Python runtime. I’m posting here because I need real feedback from developers who’d actually use this.

pip install nano-empire-tollbooth

Here’s the elevator pitch, warts and all.


How It Works

from nano_empire_tollbooth import monetize

@monetize(price_usd=0.01)
def analyze_sentiment(text: str) -> dict:
    # Your expensive API call or model inference
    return {"score": 0.95}
Enter fullscreen mode Exit fullscreen mode

100 calls free. Then it meters. The caller agent hits a payment wall, pays via Stripe, and the function resumes. No platform fees, no central billing service—you own the Stripe account.


The Stack

  • nano-empire-tollbooth (Python SDK) – decorator + metering engine
  • tollbooth-mcp – MCP server demo that shows the loop inside Claude Desktop
  • Simulator – neuralempireai.com/simulator/ (see the end-to-end flow live)
  • GitHub – MIT license, fully open: github.com/roblambert9/nano-empire-tollbooth

What’s Actually Real (and What’s Not)

✅ Real:

  • The decorator, metering, and Stripe integration all work.
  • 100 free calls per function, then it enforces payment.
  • Tollbooth Pro ($19/mo self-hosted) is functional.
  • The full cycle (agent hits paywall → pays → function returns result) is demoed in the simulator.

⚠️ Paper Mode:

  • On-chain settlement is simulated. The current version uses traditional Stripe payments. The smart contract/x402-style loop is a placeholder.
  • I haven’t stress-tested concurrent agent calls or built a proper Stripe webhook reconciliation layer yet.
  • No production users. $0 revenue. This is pre-traction.

Why I’m Posting This

I’m a solo

Neuralempireai (https://neuralempireai.com/simulator/)
Nano Empire Tollbooth Simulator
PAPER_MODE demo only. Discover tool -> quote call -> meter usage -> local ledger -> tamper-evident receipt.

Top comments (1)

Collapse
 
topstar_ai profile image
Luis

This is an interesting primitive — you’re essentially turning function calls into billable API boundaries, which is where most agent economics are heading anyway.

The hard part isn’t the decorator or Stripe flow, it’s everything around it: trust, concurrency safety, and making sure “payment gating” doesn’t become a failure mode under load or retries.

But the core idea is solid: if agents become consumers of tools, then tools will inevitably need native metering at the execution layer, not just at the platform layer.