@dnorio/agent-meter
v0.1.5
Published
Lightweight SDK to track AI agent tool calls, costs, and latency.
Downloads
82
Maintainers
Readme
@dnorio/agent-meter
Lightweight Node.js/TypeScript SDK to track AI agent tool calls, costs, and latency.
Install
npm install @dnorio/agent-meterFrom a local tarball:
cd sdk/node && npm ci && npm pack
npm install ./dnorio-agent-meter-0.1.0.tgzQuick Start (60 seconds)
import { AgentMeter } from "@dnorio/agent-meter";
const am = new AgentMeter({ apiKey: "am_live_..." });
// Track a tool call
const span = am.track("web_search", { model: "gpt-4o" });
const result = await doWebSearch(query);
am.finish(span);
// Track with tokens/cost
const span2 = am.track("code_review", { model: "claude-sonnet-4-20250514" });
span2.estimatedInputTokens = 2000;
span2.estimatedOutputTokens = 500;
span2.usdCost = 0.012;
am.finish(span2);
// Flush happens automatically every 5s
// Force flush:
await 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 | node-sdk |
| AGENT_METER_AGENT | Agent name | — |
Or pass via constructor:
const am = new AgentMeter({
apiKey: "am_live_...",
endpoint: "http://localhost:3000",
ide: "my-custom-agent",
agent: "research-bot",
});Conversations & Tasks
const span = am.track("generate_code", {
model: "claude-sonnet-4-20250514",
conversationId: "conv-abc123",
taskId: "implement-feature-x",
});Protocol
The SDK sends spans as OTLP-compatible JSON to POST /v1/traces.
