Observed since 20 Oct, 22:43 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Track LLM costs per user. Open source SDK for AgentMeter.
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.
pip install agentmeter-sdk
With provider-specific extras:
pip install agentmeter-sdk[openai]
pip install agentmeter-sdk[anthropic]
pip install agentmeter-sdk[all]
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.
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.
)
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(...)
| Provider | Sync | Async | Streaming |
|---|---|---|---|
| OpenAI | Yes | Yes | Yes |
| Anthropic | Yes | Yes | Yes |
Flush pending events before your process exits:
agentmeter.shutdown()
MIT
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0 | 16 Feb 2026 | 8 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 22:43 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:d88e27b77a2d4209876fdce92211f4762f7d9b596577b3145f460b48f702c032