Skip to main content

Lightweight LLM wrapper with usage tracking and label support

Project description

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"}}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leanllm_ai-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leanllm_ai-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file leanllm_ai-0.1.0.tar.gz.

File metadata

  • Download URL: leanllm_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for leanllm_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 19c42ff90be580b2ae7a88b7e8962bbf0fb81c95e85953ad39f32ee8724c9633
MD5 c0d69e231dd10b3b3d39b946d1d3a800
BLAKE2b-256 d5e2ad13f1dc9077b754206fe7efdc584758610d1562c5e8d569678c156b1c52

See more details on using hashes here.

File details

Details for the file leanllm_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: leanllm_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for leanllm_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f4a66b461ba8e645b493963f029e6f9f8ee9ea7c93212ee96d20aa2c9be0c68
MD5 4e229986c350dd42f57d7a3e4b351c66
BLAKE2b-256 98061f3d6abfd8923e93c94185738b8ec65cf8d807c754e0d27274b11ebb15ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page