Skip to main content

A tiny Python library for tracking LLM token usage, latency, and estimated cost.

Project description

llm-cost-profiler

PyPI version License

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


Download files

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

Source Distribution

llm_cost_profiler-0.1.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

llm_cost_profiler-0.1.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

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

Hashes for llm_cost_profiler-0.1.2.tar.gz
Algorithm Hash digest
SHA256 262a9db9b109c921efdd398a3a9f5061a68a739b158370e4765ad5324f4502dd
MD5 d6cced4287039ab8422d68123a037979
BLAKE2b-256 266ce8a914783b3f2cff6a7a3068c09c2f1e249963e1b0038d0abf96695d8437

See more details on using hashes here.

File details

Details for the file llm_cost_profiler-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_cost_profiler-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5782bb8fca67c24aa0f33f5f24cdd65988455dacddbd75b6928f27f38c0a31cd
MD5 5b2662c40e9a3775d14dccf09ca1ad7e
BLAKE2b-256 30a1eb889b6a7c70e479b2e1925834307e61084fea02a14110b5b6e6df7a90bb

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