Metadata-Version: 2.4
Name: nano-empire-tollbooth
Version: 0.2.1
Summary: Monetize any Python function with one decorator. Free tier: 100 calls. Upgrade: $19/mo.
Author-email: Nano Empire <ops@nano-empire.dev>
License: MIT
Keywords: a2a,agent,tollbooth,micropayment,settlement,mesh
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
Dynamic: license-file

# nano-empire-tollbooth

Monetize any Python function with one decorator.

```python
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

```bash
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

```python
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

```python
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:

```bash
TOLLBOOTH_PAPER_MODE=false  # enable live payments
```

## License

MIT
