Skip to main content

Monetize any Python function with one decorator. Free tier: 100 calls. Upgrade: $19/mo.

Project description

nano-empire-tollbooth

Monetize any Python function with one decorator.

from nano_empire_tollbooth import monetize

@monetize(price_usd=0.01)
def summarize(text: str) -> str:
    return my_llm(text)

That's it. Every call to summarize() is metered, logged, and settled.

Install

pip install nano-empire-tollbooth

How it works

  1. Decorate any function (sync or async) with @monetize(price_usd=...)
  2. First 100 calls run free in paper mode — full functionality, no charge
  3. After 100 calls, you get a prompt to upgrade to Tollbooth Pro ($19/mo)
  4. Pro unlocks live payments via x402 — agents pay real USD per call
from nano_empire_tollbooth import monetize

# Async works too
@monetize(price_usd=0.05)
async def translate(text: str, lang: str) -> str:
    return await my_async_llm(text, lang)

# Check your usage
from nano_empire_tollbooth import get_usage
print(get_usage())  # {'__main__.summarize': 42, '__main__.translate': 7}

What you get

Free Pro ($19/mo)
Calls 100 paper-mode Unlimited
Payments Simulated Live USD via x402
Ledger Local JSONL Local JSONL + cloud sync
Escrow Paper receipts Real settlement
Daily limits Per-agent caps Per-agent caps

Configuration

from nano_empire_tollbooth import TollboothConfig, create_tollbooth

config = TollboothConfig(
    toll_per_message_usd=0.01,   # default rate
    paper_mode=True,              # False for live payments
    max_daily_toll_per_agent=10,  # daily cap per agent
)
booth = create_tollbooth(config)

Or set via environment:

TOLLBOOTH_PAPER_MODE=false  # enable live payments

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nano_empire_tollbooth-0.2.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nano_empire_tollbooth-0.2.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file nano_empire_tollbooth-0.2.0.tar.gz.

File metadata

  • Download URL: nano_empire_tollbooth-0.2.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for nano_empire_tollbooth-0.2.0.tar.gz
Algorithm Hash digest
SHA256 409873a916ab3d2eab0defc8ce308a209e56edc3e17ac8b067304c79ffe9dc20
MD5 97958fb393fec51311a5acc1f3871c48
BLAKE2b-256 d0168481bceb004a811a61a97a49ffe5b1b214bc68e908b8ef913955c121dfd9

See more details on using hashes here.

File details

Details for the file nano_empire_tollbooth-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nano_empire_tollbooth-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5dea13933678df6e541533492f75d21081fdf79501161f0c9d5d34f01fd93ed0
MD5 9eb3fe20f6bc907ef95975762012f438
BLAKE2b-256 94f3f36c29d7360be54d3b21b242471327d230a4f19fed63496daef0ccd57e0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page