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.1.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.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nano_empire_tollbooth-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 21d0c6a027ac6f878e4aef5f684549ea9ded4cfc14963581d05fb61daea60745
MD5 d9e20dc0e236b308cb378d78b59ce872
BLAKE2b-256 dea70c475555db737c9572c3aadcdea53778060f0799431e4e587628c84c0d35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nano_empire_tollbooth-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c7be98e0525b01ee8a6f648056e9294651402e5b56758811e8e767889b6297a5
MD5 627aff47f4cdaa62efddf49649d2efdb
BLAKE2b-256 2e5c4d42e119b43ea77b912b17e6dd40d2e7d55f58d99ab5c70bf52cb84d99af

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