Model Meter — AI cost tracking

Tutorial

How to Track AI Costs by Project in Under 10 Minutes

A step-by-step guide to attributing LLM spend to specific projects, features, and teams using Model Meter's TypeScript SDK and OpenTelemetry.

All posts
Model Meter Team6 min read
tutorial, cost-attribution, sdk, getting-started

The problem

You just got a $4,000 OpenAI invoice. Which project caused it? Which feature? Which engineer's code? Without attribution, AI spend is a black box — you know the total but not the breakdown.

Provider dashboards show aggregate spend but can't tell you which internal project or feature generated a specific request. That gap is what cost attribution solves.

The 10-minute setup

Install the Model Meter SDK, then add two lines to your app:

import { init } from '@model-meter/sdk';

init({
  apiKey: process.env.MODEL_METER_API_KEY,
  endpoint: process.env.MODEL_METER_ENDPOINT,
  projectId: 'my-app',
  environment: 'production',
});

After init(), every generateText() and streamText() call is captured automatically via OpenTelemetry — no per-call changes needed.

Label calls by operation (optional but recommended)

Use the @model-meter/sdk wrapper instead of importing from 'ai' to add an operation label to each call:

import { generateText } from '@model-meter/sdk';

const result = await generateText({
  model: openai('gpt-4o'),
  prompt: 'Summarize this ticket',
  modelMeter: { operation: 'summarize-ticket' },
});

Operations appear as a breakdown dimension in the dashboard — alongside project, provider, model, and environment.

What you see in the dashboard

After your first requests, the dashboard shows spend by project, provider, model, and operation — updated in near real-time, not end-of-month. You'll see which feature is spending what, which model is most cost-efficient for each task, and where the anomalies are.

Model Meter on GitHub → · Read the getting started guide →

Not a proxy

Model Meter doesn't sit in the critical path of your AI calls. The SDK instruments existing calls via OpenTelemetry and sends telemetry asynchronously. Your AI requests go directly to the provider, so tracking adds no latency and introduces no new failure point. Prompts and completions are never collected.

Launch offer

Lock in the best launch pricing.

Join the Waitlist