agent-meter
Lightweight Python SDK to track AI agent tool calls, costs, and latency.
Install
pip install agentmeter-obs
# or
pip install dnorio-agent-meter
# From source:
cd sdk/python && python3 -m pip install -e .
Quick Start (60 seconds)
from agent_meter import AgentMeter
# Initialize (picks up AGENT_METER_API_KEY from env)
am = AgentMeter(api_key="am_live_...")
# Track a tool call
span = am.track("web_search", model="gpt-4o")
result = do_web_search(query)
span.finish()
# Track with tokens/cost
span = am.track("code_review", model="claude-sonnet-4-20250514")
span.estimated_input_tokens = 2000
span.estimated_output_tokens = 500
span.usd_cost = 0.012
span.finish()
# Flush happens automatically every 5s, or on exit
# Force flush:
am.flush()
Configuration
| Env Variable | Description | Default |
|---|---|---|
AGENT_METER_API_KEY |
API key (am_live_...) |
— |
AGENT_METER_ENDPOINT |
Server URL | http://localhost:8081 |
AGENT_METER_IDE |
IDE identifier | python-sdk |
AGENT_METER_AGENT |
Agent name | — |
Or pass directly:
am = AgentMeter(
api_key="am_live_...",
endpoint="http://localhost:3000",
ide="my-custom-agent",
agent="research-bot",
)
Context Manager
import contextlib
@contextlib.contextmanager
def tracked(am, tool_name, **kwargs):
span = am.track(tool_name, **kwargs)
try:
yield span
except Exception as e:
span.finish(ok=False, error=str(e))
raise
else:
span.finish()
# Usage
with tracked(am, "database_query", model="gpt-4o") as span:
results = db.execute(sql)
span.estimated_input_tokens = len(sql) // 4
Conversations & Tasks
Group spans into conversations (sessions) and tasks:
span = am.track(
"generate_code",
model="claude-sonnet-4-20250514",
conversation_id="conv-abc123",
task_id="implement-feature-x",
)
Protocol
The SDK sends spans as OTLP-compatible JSON to POST /v1/traces. This is the
same format used by OpenTelemetry, making it compatible with any OTLP collector.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
agentmeter_obs-0.1.1.tar.gz
(4.9 kB
view details)
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 agentmeter_obs-0.1.1.tar.gz.
File metadata
- Download URL: agentmeter_obs-0.1.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
066cf41e617029b6f5a57ac15d1bd5cbe683cdefa99a8b8eb3e1c9b568587e41
|
|
| MD5 |
ed2c890ffe941a2d03429ac7ea471e32
|
|
| BLAKE2b-256 |
4bfd480962ffdef9d00963af60e7fc467ea29093a4f58adf0e4eb7b873e0ad09
|
File details
Details for the file agentmeter_obs-0.1.1-py3-none-any.whl.
File metadata
- Download URL: agentmeter_obs-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdabef9781fee3fdca15e0cfc2839bb8ea9e61f37073d82b37036065c601af87
|
|
| MD5 |
fbf56080c7a1cbe9dceb7ba391211afd
|
|
| BLAKE2b-256 |
6cef2ab3fbba6feb00e8f9b96862ef5a71a3a4e2d31904d76f72391f9f142b50
|