Model Meter — AI cost tracking

Model Meter

How it works

Model Meter captures AI usage via OpenTelemetry without sitting in the critical path of your requests. Two-line SDK integration.

Step 1: Install the SDK

Add the npm package to your app — it instruments the Vercel AI SDK via OpenTelemetry. Full setup guide: https://github.com/jayanti-prajapati/model-meter/blob/main/docs/GETTING-STARTED.md

  • npm install @model-meter/sdk

Step 2: Call init() once at startup

Call init() once at application startup — before any AI calls are made. This is the only required code change.

  • import { init } from '@model-meter/sdk'
  • init({ apiKey, endpoint, projectId, environment })
  • Call init() in instrumentation.ts or your app's entry point

Step 3: Auto-track via OpenTelemetry

If you use the Vercel AI SDK, add the OTel span processor once. After that, every generateText(), streamText(), generateObject(), and embed() call is captured automatically — no per-call changes needed.

  • createModelMeterExporter connects the OTel span processor
  • gen_ai.* spans from the Vercel AI SDK are captured automatically
  • Input tokens, output tokens, cached tokens, latency, and cost are all tracked
  • SDK buffers events locally and flushes every 5 seconds or 50 events
  • SDK failures are silent — they never break your primary AI request

Step 4: Label by operation (optional)

Use the @model-meter/sdk wrapper instead of importing from 'ai' to add an operation label to each call. Operations appear as a breakdown dimension in the dashboard — useful for attributing costs to specific features.

  • import { generateText } from '@model-meter/sdk' — drop-in for 'ai'
  • Add modelMeter: { operation: 'summarize-ticket' } to any call
  • Operations appear alongside provider, model, project, and environment

Supported providers

The SDK captures usage from any provider supported by the Vercel AI SDK via OpenTelemetry. Verified providers with full pricing records: OpenAI (GPT-4o, GPT-4o-mini, GPT-4 Turbo, GPT-3.5), Anthropic (Claude 3.5 Sonnet, Claude 3.5 Haiku, Claude 3 Opus), Google Gemini (1.5 Pro, 1.5 Flash, 2.0 Flash), Mistral, Groq, and Cohere.

Not a proxy

Model Meter does not sit in the critical path of your AI calls. The SDK instruments calls via OpenTelemetry and sends telemetry asynchronously. Your AI requests go directly to the provider. There is no latency overhead, no single point of failure, and no prompts or completions are collected by default.

Launch offer

Lock in the best launch pricing.

Join the Waitlist