Monetize any Python function with one decorator. 100 free calls, then Pro for ledger analytics, CSV/JSON export, and higher limits.
Project description
nano-empire-tollbooth
Monetize and meter 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)
Every call is metered and logged to a local JSONL ledger. The first 100 calls print an upgrade prompt once you cross the limit; the function keeps working.
Live demo: watch a full agent payment round-trip (paper mode, $0.00 real) at neuralempireai.com/simulator.html.
Don't want to wire it up yourself? We instrument your MCP server or API with metered Stripe billing — flat $299, ships in paper mode, your Stripe account, you keep 100% of revenue. Contact: rob@nanoempireai.com.
Install
pip install nano-empire-tollbooth
Python 3.9+, one dependency (pydantic).
Command line
The package ships a tollbooth command that works over your local ledger:
tollbooth status # show tier (free/pro) and a ledger summary
tollbooth report # aggregate: calls, spend, by status
tollbooth report --json # same, machine readable
tollbooth verify # integrity check of the ledger file
tollbooth export --format csv # export the ledger (Pro)
Free vs Pro
What Pro actually unlocks today. No overstated claims.
| Free | Pro ($19/mo) | |
|---|---|---|
| Metered calls | Unlimited (paper mode) | Unlimited (paper mode) |
| Local JSONL ledger | Yes | Yes |
report and verify |
Yes | Yes |
| Upgrade prompt | Shown after 100 calls | Suppressed |
tollbooth export (CSV/JSON) |
No | Yes |
| Default daily cap | $10 / agent | $1000 / agent |
Activate Pro by setting the key you receive after purchase:
export TOLLBOOTH_LICENSE_KEY=your-key
Get a key: https://buy.stripe.com/14A9ATaI76K8gjo9JE1Nu0h
License validation is an offline check today (honor-system v1). Server-side validation is on the roadmap.
Live settlement (experimental)
The tollbooth includes an x402 hook so you can wire your own live settlement verifier:
from nano_empire_tollbooth import Tollbooth, TollboothConfig
booth = Tollbooth(TollboothConfig(paper_mode=False))
async def my_verifier(wallet, tx_signature, amount_usd):
# verify a real on-chain or off-chain payment, return True/False
return await check_payment(wallet, tx_signature, amount_usd)
booth.set_x402_verifier(my_verifier)
This ships the escrow lifecycle (lock, release, refund) and the verifier hook. It does NOT include a hosted settlement backend. Connecting real funds is your responsibility and is on the project roadmap. This is informational and not financial advice.
How metering works
- Decorate any sync or async function with
@monetize(price_usd=...). - Each call writes a record to
logs/toll_ledger.jsonlwith a settlement hash. - In paper mode (default) nothing is charged. Set
paper_mode=Falseplus your own verifier to move real funds.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nano_empire_tollbooth-0.2.5.tar.gz.
File metadata
- Download URL: nano_empire_tollbooth-0.2.5.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f363d4a798bd24fbcb1e9024279b4075c2d532169346542ad4a71a5044295c4
|
|
| MD5 |
bbd33807904bd0de7099a40299b48b9d
|
|
| BLAKE2b-256 |
aef758cfa051c8ce4e22505b50e4706e20f039a866078737017fde3eb4d92978
|
File details
Details for the file nano_empire_tollbooth-0.2.5-py3-none-any.whl.
File metadata
- Download URL: nano_empire_tollbooth-0.2.5-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3544090ab743b5bd8611100d3214b3fab1f74c0d7eceb797888d13ab63324016
|
|
| MD5 |
ff330421febc61c90a743ea59c803689
|
|
| BLAKE2b-256 |
96078a471b5f4d035eb4bdcbd84ecd0ad89e3562f2c6adca4af29fc18f0bb8d7
|