A tiny Python library for tracking LLM token usage, latency, and estimated cost.
Project description
llm-cost-profiler
Lightweight LLM cost, token, and latency profiler for any Python AI stack.
Overview
llm-cost-profiler is a small, dependency-light Python library for tracking LLM usage, latency and estimated cost across different model providers. It provides simple instrumentation primitives (manual recording and a decorator), JSONL logging for audit and analysis, and optional dynamic pricing lookups.
Perfect for developers building RAG systems, agents, batch inference jobs, Streamlit apps, FastAPI services, and more.
Features
- Token usage (prompt & completion) tracking
- Model-specific cost estimation
- Latency & response time tracking
- JSONL logging sink for audits & dashboards
- Simple decorator to profile function calls
- Dynamic pricing (optional) with safe fallbacks
- Minimal dependencies
Installation
Install from PyPI:
pip install llm-cost-profiler
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_cost_profiler-0.1.2.tar.gz.
File metadata
- Download URL: llm_cost_profiler-0.1.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
262a9db9b109c921efdd398a3a9f5061a68a739b158370e4765ad5324f4502dd
|
|
| MD5 |
d6cced4287039ab8422d68123a037979
|
|
| BLAKE2b-256 |
266ce8a914783b3f2cff6a7a3068c09c2f1e249963e1b0038d0abf96695d8437
|
File details
Details for the file llm_cost_profiler-0.1.2-py3-none-any.whl.
File metadata
- Download URL: llm_cost_profiler-0.1.2-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.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5782bb8fca67c24aa0f33f5f24cdd65988455dacddbd75b6928f27f38c0a31cd
|
|
| MD5 |
5b2662c40e9a3775d14dccf09ca1ad7e
|
|
| BLAKE2b-256 |
30a1eb889b6a7c70e479b2e1925834307e61084fea02a14110b5b6e6df7a90bb
|