Metadata-Version: 2.4
Name: tokensbill
Version: 0.1.0
Summary: One line. Every AI token tracked. Captures Anthropic/OpenAI/Gemini token usage from outgoing httpx/requests calls and streams it to TokensBill. Silent-fail by design.
License: MIT
Project-URL: Homepage, https://tokensbill.com
Project-URL: Repository, https://github.com/oxtrys/tokensbill
Keywords: ai,tokens,cost,openai,anthropic,gemini,observability,tokensbill
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# tokensbill

**One line. Every AI token tracked.** Automatically captures Anthropic / OpenAI / Gemini token usage from your app's outgoing AI calls and streams it to your [TokensBill](https://tokensbill.com) dashboard — so you can see exactly where your AI spend goes.

## Install

```bash
pip install tokensbill
```

## Use — one line at startup

```python
import tokensbill; tokensbill.init("tl_live_your_project_key")
```

Put it at the top of your entry file (e.g. `main.py`), before your app starts. That's it — every AI API call your app makes is now tracked automatically.

Get your project key from **TokensBill → your project → Integration**.

## What it does

- Patches `httpx` and `requests` (used by the Anthropic/OpenAI Python SDKs).
- Reads token counts and cost from the AI provider's response **without altering your call**.
- Sends the numbers to TokensBill in a background thread.
- **Silent-fail by design** — it never raises into, blocks, or slows your application. If TokensBill is unreachable, your app is completely unaffected.

## Is the key safe to commit?

The tracking key is a **label, not a password**. It cannot access your AI provider account, read your prompts, or spend money — it only lets your app report usage numbers to your dashboard. You can regenerate it any time from the dashboard.

## Options

```python
import tokensbill
tokensbill.init(
    "tl_live_...",
    environment="production",   # production | staging | development
    ingest_base_url="https://tokensbill.aiappsjunction.com",  # override the endpoint
)
```

## License

MIT
