Monetize any Python function with one decorator. Unlimited paper-mode metering, a one-time upgrade prompt around call 100, local ledger, signed receipts; Pro adds CSV/JSON export, higher caps, and CLI tools.
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. Paper-mode metering is unlimited and free — a one-time upgrade prompt prints around call 100, and the function keeps working (it nags, it does not block).
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)
tollbooth settle # batch-net released tolls into one charge-sized settlement (paper mode; --live fails closed until you wire your own rail)
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 |
Pro is in private setup and not yet purchasable. The licensing pipeline (Ed25519-signed keys + checkout issuance) is built and tested but not wired live yet — so there's no buy link here on purpose. Watch the repo for availability.
When you have a key, activate it with:
export TOLLBOOTH_LICENSE_KEY=your-key
License validation is a real offline check: each key carries an Ed25519 signature from the issuer plus an expiry, verified locally with the published public key — no secret, no phone-home. A random, tampered, or expired key does not unlock Pro. Online revocation before expiry 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.3.0.tar.gz.
File metadata
- Download URL: nano_empire_tollbooth-0.3.0.tar.gz
- Upload date:
- Size: 29.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7978542b76be90a23e3db783fd66cc9f4256de00d5efe9012debcabcb09e854a
|
|
| MD5 |
b4b58f8bd2329cff609fbf7be50b2e5c
|
|
| BLAKE2b-256 |
ff65be73ff11588f3dd102ec9d74f8dec3b24048058f9f5a6a52cec160ee9b5c
|
Provenance
The following attestation bundles were made for nano_empire_tollbooth-0.3.0.tar.gz:
Publisher:
publish.yml on roblambert9/nano-empire-tollbooth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nano_empire_tollbooth-0.3.0.tar.gz -
Subject digest:
7978542b76be90a23e3db783fd66cc9f4256de00d5efe9012debcabcb09e854a - Sigstore transparency entry: 1854742731
- Sigstore integration time:
-
Permalink:
roblambert9/nano-empire-tollbooth@d0ef21ae3133582319a249d41de97b80be7b00ae -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/roblambert9
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d0ef21ae3133582319a249d41de97b80be7b00ae -
Trigger Event:
push
-
Statement type:
File details
Details for the file nano_empire_tollbooth-0.3.0-py3-none-any.whl.
File metadata
- Download URL: nano_empire_tollbooth-0.3.0-py3-none-any.whl
- Upload date:
- Size: 23.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4011185daacdafa4cee90509ada388df91fba43e6b088b5a4ca8e65d4e8e37c2
|
|
| MD5 |
52f33465bcb1e02aa86ddd29500caea3
|
|
| BLAKE2b-256 |
f308e80fc65e2c215ce322518af9ae51021995bf0ac77dc05b1d65e0a1e85ec7
|
Provenance
The following attestation bundles were made for nano_empire_tollbooth-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on roblambert9/nano-empire-tollbooth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nano_empire_tollbooth-0.3.0-py3-none-any.whl -
Subject digest:
4011185daacdafa4cee90509ada388df91fba43e6b088b5a4ca8e65d4e8e37c2 - Sigstore transparency entry: 1854742785
- Sigstore integration time:
-
Permalink:
roblambert9/nano-empire-tollbooth@d0ef21ae3133582319a249d41de97b80be7b00ae -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/roblambert9
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d0ef21ae3133582319a249d41de97b80be7b00ae -
Trigger Event:
push
-
Statement type: