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. Set it as LEAK_KEY in your env (alongside
ANTHROPIC_API_KEY).
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
Metadata
Release files for useleak 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| useleak-0.4.0.tar.gz | 5.5 kB | Without provenance | Details for useleak-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| useleak-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for useleak-0.4.0-py3-none-any.whl |
Total release size: 11.1 kB
Release files / useleak-0.4.0.tar.gz
| Download URL | useleak-0.4.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00031408acf013dfcb8dec5c975e51c7d976227451322d1ca3d4efc0eeb11735
|
|
BLAKE2b-256 checksum How to use checksums |
59078c8338ccac8b6b5f71e6f97e04561c840133826dd47a1405cb361e50b92a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / useleak-0.4.0-py3-none-any.whl
| Download URL | useleak-0.4.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eee093332f099ac050feecce77e387830255632a5c2d05782c78143a2bd0925c
|
|
BLAKE2b-256 checksum How to use checksums |
b18b522a16c73a00bb08b09b5ff2bdbcd03c8959f09a217d4aa1e30bdf83924e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for useleak 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.