Metadata-Version: 2.4
Name: useleak
Version: 0.3.0
Summary: Drop-in cost tracking for Anthropic, OpenAI, and Google Gemini SDKs — see exactly where your LLM spend goes.
Project-URL: Homepage, https://useleak.cloud
Project-URL: Repository, https://github.com/bennetglinder1/leak
Project-URL: Documentation, https://github.com/bennetglinder1/leak#readme
Author: Bennet Glinder
License: MIT
Keywords: anthropic,claude,cost,gemini,leak,llm,observability,openai,tracking
Classifier: Development Status :: 3 - Alpha
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
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Provides-Extra: all
Requires-Dist: anthropic>=0.30.0; extra == 'all'
Requires-Dist: google-genai>=0.1.0; extra == 'all'
Requires-Dist: openai>=1.0.0; extra == 'all'
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.30.0; extra == 'anthropic'
Provides-Extra: google
Requires-Dist: google-genai>=0.1.0; extra == 'google'
Provides-Extra: openai
Requires-Dist: openai>=1.0.0; extra == 'openai'
Description-Content-Type: text/markdown

# useleak (python)

Drop-in cost tracking for the Anthropic Python SDK. See exactly where your LLM
spend goes — broken down by feature, user, and model.

## Install

```
pip install useleak
```

## Usage

Get a workspace SDK key from **Settings → Workspace SDK key** in your [Leak
dashboard](https://useleak.cloud). Set it as `LEAK_KEY` in your env (alongside
`ANTHROPIC_API_KEY`).

```python
import os
from useleak import Anthropic

client = Anthropic()  # picks up ANTHROPIC_API_KEY + LEAK_KEY from env

response = client.messages.create(
    model="claude-opus-4-7",
    feature="icp-scoring",     # ← the one extra param Leak needs
    user="user_123",            # optional but lets you group by customer
    max_tokens=1024,
    messages=[{"role": "user", "content": "..."}],
)

print(response.content[0].text)
```

That's it. Every call gets tracked to your Leak dashboard within a few seconds:
model, tokens in/out, cost, feature, user, request ID.

## API

`useleak.Anthropic` accepts every kwarg the official `anthropic.Anthropic`
accepts, plus two of its own:

| Parameter | Default | Description |
|---|---|---|
| `leak_key` | `LEAK_KEY` env | Your workspace SDK key (`lk_live_...`) |
| `leak_url` | `https://useleak.cloud/api/ingest` | Ingest endpoint, override only if self-hosting |

`client.messages.create(...)` accepts every kwarg the Anthropic SDK accepts,
plus three of its own:

| Parameter | Required | Description |
|---|---|---|
| `feature` | recommended | The feature in your app that triggered this call (`"icp-scoring"`, `"playground"`, etc.) |
| `user` | optional | An end-user identifier — lets you see who is burning tokens |
| `api_key_label` | optional | Free-form label like `"Production"` / `"Staging"` |

Tracking is async and non-blocking. If `useleak.cloud` is down, your Anthropic
call still succeeds — Leak failures never propagate.

## What it tracks

- model
- input tokens / output tokens
- USD cost (computed locally from the Anthropic price table)
- feature, user, api_key_label (your tags)
- Anthropic request ID

It does **not** send prompts, responses, or any message content.

## License

MIT
