Source library / Concepts

Report Usage, Not Cost

Why AI agent instrumentation should emit raw usage metrics while the backend calculates dollars.

Short answer

Report usage, not cost means application code records facts such as tokens, characters, requests, or seconds. The backend calculates dollars from pricing tables. This keeps pricing editable, customer-specific, auditable, and independent from code deploys.

Query paths
  • - Should the SDK send cost_usd?
  • - How should AI usage metering handle pricing changes?
  • - How do I support per-customer pricing without changing code?

The Rule

Hot-path application code should describe what happened. It should not decide the commercial value of what happened.

For LLM calls, the SDK reports model and token usage. For non-LLM work, code reports a metric and value. AgentMeter applies pricing centrally.

Why It Matters

Vendor prices change. Customer contracts differ. Billing rules evolve. Moving cost math out of runtime code lets founders adjust pricing without asking engineering to redeploy every integration.

Runtime reportsDashboard ownsOutcome
tokens_in and tokens_outmodel price tableLLM spend
charactersspeech price per unitTTS or STT spend
requestssearch API priceretrieval spend
executionsworkflow priceautomation spend

A Small Example

The agent reports 4,200 characters for a speech step. AgentMeter applies the builder's current ElevenLabs-style character price and attributes the result to the customer.

Runtime emits usage only
import { reportUsage } from "@agentmeter/sdk";

reportUsage({
  customer_id: "acme-corp",
  tool: "tts",
  metric: "characters",
  value: 4200,
  step: "speak_answer",
});
FAQ
Why not send cost_usd directly?

That makes runtime code responsible for pricing and creates drift when vendor rates or customer contracts change.

Does this work for LLM and non-LLM sources?

Yes. LLM usage maps to model pricing; non-LLM usage maps to builder-configured metric pricing.

Can historical prices change?

AgentMeter treats pricing changes as versioned forward changes, not silent rewrites of old usage.

Related reading