Catalog PyPI
Back to packageRELEASE DETAILS

0.1.0

PyPI

agentmeter-sdk

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

Published16 Feb 2026
Direct dependencies8
Transitive dependenciesNot calculated

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.

Declared dependencies 12

Native requirements
8 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
requests
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
requests>=2.28.0runtime
openai
Environment
{
  "extras": "",
  "marker": "extra == \"openai\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
openai>=1.0.0; extra == "openai"runtime
anthropic
Environment
{
  "extras": "",
  "marker": "extra == \"anthropic\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
anthropic>=0.18.0; extra == "anthropic"runtime
openai
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
openai>=1.0.0; extra == "all"runtime
anthropic
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
anthropic>=0.18.0; extra == "all"runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest>=7.0; extra == "dev"runtime
pytest-asyncio
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest-asyncio>=0.21; extra == "dev"runtime
pytest-mock
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest-mock>=3.10; extra == "dev"runtime
responses
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
responses>=0.23; extra == "dev"runtime
ruff
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
ruff>=0.1.0; extra == "dev"runtime
openai
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
openai>=1.0.0; extra == "dev"runtime
anthropic
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
anthropic>=0.18.0; extra == "dev"runtime

Distribution files

1 collected
agentmeter_sdk-0.1.0-py3-none-any.whl

bdist_wheel · 8.94 KB · Python py3

Source file

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_version:beed6ddbf2816e8c3737dde93edd14ef097e17ad2ebc33dcfffeb45e3bcd49e3

Other collected versions

View all collected versions →