Skip to main content

See where your LLM money goes. Get told exactly how to cut it.

Project description

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

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

useagentlens-0.1.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

useagentlens-0.1.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file useagentlens-0.1.0.tar.gz.

File metadata

  • Download URL: useagentlens-0.1.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for useagentlens-0.1.0.tar.gz
Algorithm Hash digest
SHA256 378c1a05a6493538d6b19d9bd6a8c01c24403baa8bd67846c869b9c998d3a146
MD5 cd6e78971551b73ba8d7a4bd318004c7
BLAKE2b-256 226983e22d9d8d0a1b0c3753952d2f57bec047f2e47a72f5e3217c1583641620

See more details on using hashes here.

File details

Details for the file useagentlens-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: useagentlens-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for useagentlens-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9ec761ee8df392df251dfe0dfd4be44daec5d5515da52df059ff0f9cfe79850
MD5 f85359e15950963f1324550f594fab41
BLAKE2b-256 a142132a783f7ec9599edd9c0bc78b031059cc2fa30d7c44520907f64e3e9afa

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