Skip to main content

Automatic observability for LLM API calls

Project description

llm-lens

Automatic observability for OpenAI and Anthropic API calls.
Tracks latency, token usage, cost, and errors — with a live web dashboard.

llm-lens dashboard


What it does

Add one import to your project. llm-lens silently intercepts every OpenAI and Anthropic API call and logs:

  • Latency (ms)
  • Input and output tokens
  • Cost in USD
  • Model used
  • Errors and status

No SDK changes. No account setup. No config files.


Installation

pip install llm-lens-py

Usage

import llm_lens        # patches OpenAI and Anthropic automatically
import openai

client = openai.OpenAI()
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "hello"}]
)
# this call was silently tracked

CLI

# show a table of all tracked calls
llm-lens

# show aggregated stats: total calls, error rate, avg latency, total cost
llm-lens stats

# start the live dashboard at http://localhost:8000
llm-lens serve

# set a cost alert threshold
llm-lens config set cost_alert_usd 0.10

Dashboard

Run llm-lens serve and open http://localhost:8000.

  • Live stats: total calls, error rate, avg latency, total cost
  • Latency per call chart
  • Error per call chart
  • Red alert banner when cost threshold is breached
  • Auto-refreshes every 5 seconds

Docker

docker build -t llm-lens .
docker run -p 8000:8000 llm-lens

Supported models

Provider Models
OpenAI gpt-4o, gpt-4o-mini, gpt-4-turbo
Anthropic claude-3-5-sonnet, claude-3-5-haiku, claude-3-opus

Data storage

All data is stored locally at ~/.llm_lens/calls.db (SQLite). Nothing leaves your machine unless you deploy the server yourself.


Stack

Python · FastAPI · SQLite · Vanilla JS · Chart.js · Docker · Render


Status

Active development. Built in 12 days as a learning project.
Feedback and PRs welcome.

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_lens_py-0.1.1.tar.gz (215.3 kB view details)

Uploaded Source

Built Distribution

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

llm_lens_py-0.1.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file llm_lens_py-0.1.1.tar.gz.

File metadata

  • Download URL: llm_lens_py-0.1.1.tar.gz
  • Upload date:
  • Size: 215.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for llm_lens_py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ff1090d177b91e39c12a0bdb875c8038ef41d1ff7068dc7a7595a6d04f7b32ed
MD5 c971815a5ae6ead9aca29228146a2c3e
BLAKE2b-256 b42f385f00e34d45187af69000d8d5b72e3263f1c0aedc96df42a3a7dc346d96

See more details on using hashes here.

File details

Details for the file llm_lens_py-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: llm_lens_py-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for llm_lens_py-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 84a662fef1aee6e0e5abc0dd66bc809303a442ab99d007e295d5611f81afad51
MD5 86b51964cc73f3225b9889e5359b062b
BLAKE2b-256 60bd7ed38a03d6a43b5acc7adef6486884ee66a5ada6714c6857c54eef314e81

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