Catalog PyPI
PACKAGE EXPLORERView in registry

agentmeter-sdk

PyPI

Track LLM costs per user. Open source SDK for AgentMeter.

Versions collected1
Direct dependencies8From release 0.1.0
Last observed20 Oct, 22:43 UTC

README

Version 0.1.0 documentation

AgentMeter SDK

Track LLM costs per user. The official Python SDK for AgentMeter.

AgentMeter automatically tracks token usage across OpenAI and Anthropic API calls, attributes costs to individual users, and reports them to your AgentMeter dashboard.

Installation

pip install agentmeter-sdk

With provider-specific extras:

pip install agentmeter-sdk[openai]
pip install agentmeter-sdk[anthropic]
pip install agentmeter-sdk[all]

Quick Start

import agentmeter

# Initialize before creating any LLM clients
agentmeter.init(api_key="am_live_xxx")

from openai import OpenAI
client = OpenAI()

# Wrap LLM calls with identify() to attribute usage to a user
with agentmeter.identify(user_id="user_123"):
    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": "Hello!"}],
    )

That's it. Token usage is automatically captured and sent to your AgentMeter dashboard.

Usage

Initialization

Call agentmeter.init() before creating any LLM client instances. This patches the OpenAI and Anthropic libraries to capture usage data.

agentmeter.init(
    api_key="am_live_xxx",   # Required. Get this from your dashboard.
    enabled=True,            # Disable to turn off tracking (e.g. in tests).
    debug=False,             # Print events to console instead of sending them.
)

Identifying Users

Use identify() as a context manager or decorator to associate LLM calls with a user:

# Context manager
with agentmeter.identify(user_id="user_123"):
    response = client.chat.completions.create(...)

# Decorator
@agentmeter.identify(user_id="user_123")
def handle_request():
    return client.chat.completions.create(...)

You can optionally pass a session_id to group multiple LLM calls into a single session:

with agentmeter.identify(user_id="user_123", session_id="sess_abc"):
    response = client.chat.completions.create(...)

Supported Providers

ProviderSyncAsyncStreaming
OpenAIYesYesYes
AnthropicYesYesYes

Shutdown

Flush pending events before your process exits:

agentmeter.shutdown()

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.016 Feb 20268

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
gregorkonzett/agentmeter-sdk

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:43 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:d88e27b77a2d4209876fdce92211f4762f7d9b596577b3145f460b48f702c032