Skip to main content

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

  1. Decorate any sync or async function with @monetize(price_usd=...).
  2. Each call writes a record to logs/toll_ledger.jsonl with a settlement hash.
  3. In paper mode (default) nothing is charged. Set paper_mode=False plus 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

nano_empire_tollbooth-0.3.0.tar.gz (29.5 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.3.0-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

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

Hashes for nano_empire_tollbooth-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7978542b76be90a23e3db783fd66cc9f4256de00d5efe9012debcabcb09e854a
MD5 b4b58f8bd2329cff609fbf7be50b2e5c
BLAKE2b-256 ff65be73ff11588f3dd102ec9d74f8dec3b24048058f9f5a6a52cec160ee9b5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for nano_empire_tollbooth-0.3.0.tar.gz:

Publisher: publish.yml on roblambert9/nano-empire-tollbooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for nano_empire_tollbooth-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4011185daacdafa4cee90509ada388df91fba43e6b088b5a4ca8e65d4e8e37c2
MD5 52f33465bcb1e02aa86ddd29500caea3
BLAKE2b-256 f308e80fc65e2c215ce322518af9ae51021995bf0ac77dc05b1d65e0a1e85ec7

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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