Skip to main content

agent-meter

Lightweight Python SDK to track AI agent tool calls, costs, and latency.

Install

pip install agentmeter-obs

# 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.

Metadata

Release files for dnor-agent-meter 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dnor-agent-meter 0.1.0
File Size Uploaded Provenance Actions
dnor_agent_meter-0.1.0.tar.gz 4.9 kB Without provenance Details for dnor_agent_meter-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dnor-agent-meter 0.1.0
File Interpreter ABI Platform Actions
dnor_agent_meter-0.1.0-py3-none-any.whl Python 3 none any Details for dnor_agent_meter-0.1.0-py3-none-any.whl

Total release size: 10.4 kB

Release files / dnor_agent_meter-0.1.0.tar.gz

Download URL dnor_agent_meter-0.1.0.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e99fae37cfea5ce5b261bc6dbd63a5f01618015247fbc816c6a712f96b590a96
BLAKE2b-256 checksum
How to use checksums
c9169c1d2cdb6a4c36df41ef8b7c68cc57f04b637826d2252ffc828758563b07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / dnor_agent_meter-0.1.0-py3-none-any.whl

Download URL dnor_agent_meter-0.1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ba5186a58b760c4fc1782d9bb7d8a85837231f903b5ca54ceb84bdbcb22ab35
BLAKE2b-256 checksum
How to use checksums
58990021e46d16a9c302ce67b380493a0ace31384d91b25bb8282ecf336db7af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for dnor-agent-meter 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page