v0.1.0 on npm

Stop Guessing your
AI Costs

Track per-task, per-workflow, per-customer costs across LLM calls, MCP tools, and agent payments. Know what each agent task actually costs.

agent.ts
import Anthropic from "@anthropic-ai/sdk";
import { init, patchAnthropic } from
  "@grislabs/agentmeter";

// One line to start tracking
init({ apiKey: process.env.AM_KEY });
const client = patchAnthropic(new Anthropic());

// Every call is now tracked
const msg = await client.messages.create({
  model: "claude-sonnet-4",
  max_tokens: 1024,
  messages: [{ role: "user", content: q }],
});

AI Agent Cost Tracking
for Engineering Teams.

Your agents make 15+ LLM calls, 8 tool calls, and trigger payments per task. We tell you what each task actually costs — per workflow, per customer.

👥

Cost by Customer

Know what each customer costs you. “Customer X spent $42.10 on 89 agent tasks this month.” Price your AI features with real data.

📊

Workflow Attribution

Per-task cost with percentiles. “resolve-ticket costs $0.13 at p50, but $4.82 at p95 — you have a runaway problem.”

🚨

Budget Controls

Kill runaway agents before they drain your budget. Per-run, daily, and monthly limits across LLM + tools + payments.

BUDGET: $5.00/run
CURRENT: $4.82 (LLM+MCP+MPP)
ACTION: KILL
🔌

Beyond LLM Costs

Track MCP tool costs, Stripe MPP payments, API calls, and compute. All cost types in one view.

LLM Cost Monitoring,
Three Ways.

From zero-config to full workflow tracing. Pick the level that fits.

01

Auto-Patch

Patch your Anthropic or OpenAI client. Every call tracked automatically.

patchAnthropic(client)
02

Workflow Tracing

Wrap agent logic in trace() for per-task cost attribution with customer tags.

trace("resolve-ticket", tags, fn)
03

MCP Middleware

Auto-track all MCP tool calls with per-tool cost configuration.

createMCPMiddleware(client, costs)

CLI Included

Check your agent costs from the terminal.

  • status — total spend, top workflows, daily trend
  • workflows — cost percentiles (p50/p95) per workflow
  • customers — cost breakdown per customer
$ npx agentmeter status
AgentMeter Overview (Mar 01 → Mar 22)
Total spend: $2,847.30
Total traces: 12,481
Errors: 23
Top workflows by cost:
resolve-ticket$1,842.10
generate-report$645.20
agent-purchase$360.00

Stop Overpaying for AI Agent Infrastructure.

Start tracking your AI unit economics in 3 minutes. Open source SDK. Hosted API.

$npm i @grislabs/agentmeter

Frequently Asked Questions

How much does an AI agent cost per task?

It depends on the workflow. A simple support chatbot costs $0.01-$0.12 per conversation. A multi-step agent with tool calls and payments can cost $1-$10+ per task. AgentMeter tracks the exact cost of each task, broken down by LLM inference, MCP tool calls, and agent payments.

How is AgentMeter different from Helicone or LangSmith?

Helicone, Portkey, and LangSmith track per-LLM-call costs. AgentMeter tracks per-task costs. When your agent makes 15 LLM calls, 8 tool calls, and a Stripe MPP payment to resolve one ticket, AgentMeter tells you the total cost of that ticket — and attributes it to a specific customer and workflow.

Does AgentMeter track MCP tool costs?

Yes. AgentMeter includes an MCP middleware that auto-tracks all tool calls with per-tool cost configuration. It also tracks Stripe MPP payments, x402 transactions, and any API call costs your agent incurs.

Can I set budget limits for AI agents?

Yes. AgentMeter supports per-run, daily, and monthly budget limits. If an agent exceeds the per-run limit, it can automatically kill the workflow, preventing runaway costs. Budget checks cover all cost types — LLM, tools, and payments combined.

What LLM providers are supported?

Anthropic, OpenAI, and Google — all models supported with built-in pricing tables and prompt caching detection. Auto-patch functions require zero code changes beyond initialization. Custom models supported via setCustomPricing().