Metadata-Version: 2.4
Name: useagentlens
Version: 0.1.0
Summary: See where your LLM money goes. Get told exactly how to cut it.
Author: AgentLens
License: MIT
Keywords: agents,anthropic,cost,llm,observability,openai
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Requires-Dist: certifi>=2024.0.0
Provides-Extra: all
Requires-Dist: anthropic>=0.40.0; extra == 'all'
Requires-Dist: openai>=1.50.0; extra == 'all'
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.40.0; extra == 'anthropic'
Provides-Extra: dev
Requires-Dist: anthropic>=0.40.0; extra == 'dev'
Requires-Dist: openai>=1.50.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Provides-Extra: openai
Requires-Dist: openai>=1.50.0; extra == 'openai'
Description-Content-Type: text/markdown

# 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

```bash
pip install useagentlens
```

## Quickstart

### Anthropic

```python
# 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

```python
# 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:

```python
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](https://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:

```bash
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:

```python
client = Anthropic(agentlens_debug=True)
```

## License

MIT
