LeanLLM
Lightweight Python wrapper around LiteLLM with built-in usage tracking and label support.
Installation
pip install leanllm
Or install locally for development:
pip install -e .
Quickstart
from leanllm import LeanLLM
client = LeanLLM(api_key="sk-...")
response = client.chat(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello!"}],
labels={"team": "backend", "feature": "onboarding"},
)
print(response.choices[0].message.content)
Labels
Every request accepts an optional labels dict. Labels are attached to the usage event logged for that call, making it easy to slice costs and latency by team, feature, environment, or any dimension you define.
Usage logs
Each call appends a JSON line to llm_logs.json (configurable via LEANLLM_LOG_FILE / LEANLLM_LOG_DIR env vars):
{"model": "gpt-4o-mini", "prompt_tokens": 12, "completion_tokens": 8, "total_tokens": 20, "latency_ms": 432.1, "labels": {"team": "backend"}}
Metadata
Release files for leanllm-ai 0.1.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 | |
|---|---|---|---|
| leanllm_ai-0.1.0.tar.gz | 4.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| leanllm_ai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.9 kB
Release files / leanllm_ai-0.1.0.tar.gz
| Download URL | leanllm_ai-0.1.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19c42ff90be580b2ae7a88b7e8962bbf0fb81c95e85953ad39f32ee8724c9633
|
|
BLAKE2b-256 checksum How to use checksums |
d5e2ad13f1dc9077b754206fe7efdc584758610d1562c5e8d569678c156b1c52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / leanllm_ai-0.1.0-py3-none-any.whl
| Download URL | leanllm_ai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f4a66b461ba8e645b493963f029e6f9f8ee9ea7c93212ee96d20aa2c9be0c68
|
|
BLAKE2b-256 checksum How to use checksums |
98061f3d6abfd8923e93c94185738b8ec65cf8d807c754e0d27274b11ebb15ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|