agentlens
One import. See where your LLM money goes. Get told exactly how to cut it.
AgentLens wraps the Anthropic and OpenAI Python SDKs to capture cost and performance telemetry — without changing how your code works or adding any latency.
Install
pip install useagentlens
Quickstart
Anthropic
# Before
from anthropic import Anthropic
# After — one line change
from agentlens import Anthropic
client = Anthropic(
agentlens_key="al_live_...", # from useagentlens.com/settings
)
# Everything else stays the same
msg = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
OpenAI
# Before
from openai import OpenAI
# After — one line change
from agentlens import OpenAI
client = OpenAI(
agentlens_key="al_live_...", # from useagentlens.com/settings
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello!"}],
)
Labelling requests
Tag your requests to group costs by feature, user session, or agent step:
client = Anthropic(
agentlens_key="al_live_...", # from useagentlens.com/settings
endpoint="customer-support", # groups costs by feature in the dashboard
session_id=user_session_id, # tracks cost across a full conversation
step=step_number, # tracks cost growth across agent steps
)
# Or override per-call without creating a new client
step2_client = client.with_options(step=2)
How it works
- Your existing Anthropic/OpenAI API key is passed straight through — AgentLens never sees it
- After each API response, usage data is read and sent to the AgentLens ingest API on a background thread
- Zero latency added to your application
- If the AgentLens API is unreachable, events are silently dropped — your code always continues normally
Dashboard
Sign in at useagentlens.com to see:
- Total spend over time
- Cost breakdown by endpoint, model, and session
- P95 latency alongside average latency
- Actionable insights: system prompt bloat, model mismatch, agent loop explosion
Optional dependencies
Install only what you need:
pip install "useagentlens[anthropic]" # Anthropic wrapper only
pip install "useagentlens[openai]" # OpenAI wrapper only
pip install "useagentlens[all]" # Both
Debug mode
No API key? Print events to stdout instead of sending them:
client = Anthropic(agentlens_debug=True)
License
MIT
Metadata
Release files for useagentlens 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| useagentlens-0.1.0.tar.gz | 12.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| useagentlens-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.6 kB
Release files / useagentlens-0.1.0.tar.gz
| Download URL | useagentlens-0.1.0.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
378c1a05a6493538d6b19d9bd6a8c01c24403baa8bd67846c869b9c998d3a146
|
|
BLAKE2b-256 checksum How to use checksums |
226983e22d9d8d0a1b0c3753952d2f57bec047f2e47a72f5e3217c1583641620
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / useagentlens-0.1.0-py3-none-any.whl
| Download URL | useagentlens-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d9ec761ee8df392df251dfe0dfd4be44daec5d5515da52df059ff0f9cfe79850
|
|
BLAKE2b-256 checksum How to use checksums |
a142132a783f7ec9599edd9c0bc78b031059cc2fa30d7c44520907f64e3e9afa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|