See where your LLM money goes. Open-source proxy for AI API cost tracking, waste detection, and budget alerts.
Project description
BurnLens
See exactly what your LLM API calls cost, per feature, team, and customer.
pip install burnlens
burnlens start
# Dashboard at http://127.0.0.1:8420/ui
The Problem
- OpenAI bills by model, not by feature. You find out at month end.
- Reasoning tokens on o1/o3 can cost 10x more than expected. There's no per-call breakdown in the invoice.
- One bad deploy can cost $47K before anyone notices. No alerts, no per-request visibility.
BurnLens is a transparent local proxy that sits between your app and the AI provider. Zero code changes. Full cost visibility.
How It Works
BurnLens runs as a local proxy. Point your SDK at it, and every request is logged with cost, latency, and your custom tags:
# Start the proxy
burnlens start
# Set the env vars it prints (or add to your .env)
export OPENAI_BASE_URL=http://127.0.0.1:8420/proxy/openai
export ANTHROPIC_BASE_URL=http://127.0.0.1:8420/proxy/anthropic
Google SDK Setup
The Google generativeai SDK does not support a base URL env var. Use the patch helper instead:
import burnlens.patch
burnlens.patch.patch_google() # call once, before any Google API usage
import google.generativeai as genai
r = genai.GenerativeModel("gemini-2.0-flash").generate_content("Hello!")
Or configure manually:
import google.generativeai as genai
genai.configure(
api_key=os.environ["GOOGLE_API_KEY"],
client_options={"api_endpoint": "http://127.0.0.1:8420/proxy/google"},
transport="rest",
)
Your existing code works unchanged for OpenAI and Anthropic. Add optional tags via headers for per-feature/team/customer tracking:
import openai
client = openai.OpenAI() # automatically uses OPENAI_BASE_URL
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
extra_headers={
"X-BurnLens-Tag-Feature": "chat",
"X-BurnLens-Tag-Team": "backend",
"X-BurnLens-Tag-Customer": "acme-corp",
},
)
What You Get
- Cost timeline -- daily spend trend across all providers
- Cost by model, feature, team, customer -- know exactly where the money goes
- Waste alerts -- context bloat, duplicate requests, model overkill
- Recent requests -- per-call cost and latency in real time
CLI Tools
burnlens top # live traffic viewer (like htop for LLM calls)
burnlens report --days 7 # cost digest report
burnlens analyze # waste detection + savings suggestions
burnlens export --days 30 # export to CSV
Configuration
Create a burnlens.yaml in your project root (optional -- everything works with defaults):
port: 8420
host: "127.0.0.1"
log_level: "info"
alerts:
terminal: true
# slack_webhook: "https://hooks.slack.com/services/T.../B.../xxx"
budget:
daily_usd: 5.00
weekly_usd: 25.00
monthly_usd: 80.00
Supported Providers
| Provider | Env Var | Models |
|---|---|---|
| OpenAI | OPENAI_BASE_URL |
gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-4, gpt-3.5-turbo, o1, o3, o3-mini, o4-mini |
| Anthropic | ANTHROPIC_BASE_URL |
claude-opus-4-5, claude-sonnet-4-5, claude-3.5-sonnet, claude-3.5-haiku, claude-haiku-4-5, claude-3-opus |
burnlens.patch.patch_google() |
gemini-2.5-pro, gemini-2.5-flash, gemini-2.0-flash, gemini-1.5-pro, gemini-1.5-flash |
All models with pricing in the provider's pricing file are supported. Unknown models are logged with cost = $0.00 and a warning.
Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
Run tests with pytest. The codebase is Python 3.10+ with type hints throughout.
License
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 burnlens-0.1.1.tar.gz.
File metadata
- Download URL: burnlens-0.1.1.tar.gz
- Upload date:
- Size: 111.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d421bcf1ef6267c6e1721ead69dd9e7bd1dfd0ba1c2e18f01c6b25925ad9088
|
|
| MD5 |
1eda2feaf37e5340c6233ce6d5daa2f9
|
|
| BLAKE2b-256 |
586d68215e02cdb79565b66d66bf85d95e225b3174bb4fb80a82d833d86f735b
|
File details
Details for the file burnlens-0.1.1-py3-none-any.whl.
File metadata
- Download URL: burnlens-0.1.1-py3-none-any.whl
- Upload date:
- Size: 68.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3aed824923f9315ece689e8286796ec6cffa792a92af45814b3e9c3464626b15
|
|
| MD5 |
1f6f5cdf7d9ef97834715036cbd7fc17
|
|
| BLAKE2b-256 |
716811b1612364053425ab5c5888f4cb8fd3385a941fbf7f0ea222c6a6c933c5
|