Skip to content
Back to the blog
Monitoring & FinOps Martin Pohl

Monitoring AI costs: what to measure, which alerts to set, and why

A practical guide to the KPIs worth watching on an LLM API, from daily spend through anomalies to runaway agents. With example alerts and the usual red flags.

Sdílet:

AI costs can triple overnight. A bug in an agent, an infinite loop, a new endpoint in production, a marketing campaign, and suddenly the invoice is $5,000 instead of $500. Without monitoring you find out from the card statement.

5 KPIs you should watch

1. Daily spend (USD)

The baseline. Watch daily spend across providers. Alert when a day’s spend exceeds 1.5× the 7-day rolling average. That catches runaway loops in hours, not days.

2. Cost per request (average)

Rising? The prompt or the context probably grew. Falling? Good news, or someone switched to a cheaper model. Check the quality.

3. Input vs output token ratio

Output tokens are typically 4–5× more expensive than input. A high output share points at an uncapped max_tokens or a needless “explain why” in the prompt. See prompt optimization.

4. Model mix

What share of requests goes through a flagship versus a mini? If the flagship does more than 30% and the workload is not reasoning-heavy, there is room to route. Detail in the model comparison.

5. Latency per model

Not only a UX metric. Slow responses also mean expensive streams, and they often signal a problem at the provider before it shows up on the invoice. Watch p50 and p95.

Alerts that mean something

  • Budget threshold — 50%, 80%, 100% of the monthly budget
  • Spike detection — hourly spend above 3× the median of the last 24 hours
  • New model usage — someone shipped a model that was not in the budget
  • Failed requests above 5% — you pay for errors (often yes, on rate limits)
  • A single request above $X — typically a runaway agent or a bad RAG setup

Red flags on the dashboard

  • A flat line, then a jump — a deploy, or a bug
  • A slow drift upward — prompts are growing, context is accumulating
  • A wave through the night — a cron job or batch processing running 24/7
  • Spend suddenly at zero — the API key was revoked, or the provider is down

A 10-minute setup

A sequence that works for a small or mid-size team:

  1. Connect OpenAI, Anthropic or OpenRouter in Tokeny
  2. Set a monthly budget alert (an email at 80%)
  3. Five minutes a week: cost per request, model mix, the five most expensive requests
  4. Estimate a new feature in the calculator before you ship it

Advanced: per-feature attribution

On a larger product, add metadata to every request (user_id, feature, endpoint). Then you know that 60% of the cost sits on 5% of users, or that an “experimental” endpoint eats more than the main product. Without per-feature tags, optimization is guessing.

What is not worth measuring

  • Token count without the price — different models, different prices. Watch USD.
  • Total requests — without cost or latency it tells you nothing
  • Daily spend without a 7-day average — weekend swings become false alerts

Related: 10 ways to cut AI costs · 2026 model comparison · Token window strategy

Related guides and price pages

LLM Cost Calculator

Estimate across 11 models

GPT API cost

Per-token prices for OpenAI models

Claude API cost

Haiku, Sonnet, Opus pricing

How to calculate LLM cost

The formula, step by step

10 ways to save

Caching, routing, batch APIs

Prompt optimization

Cut tokens by 30–60%

Token window strategy

RAG, sliding window, pruning

Track real AI spend, not just estimates

Upload a CSV from Cursor, Grok Bot or OpenRouter and see daily spend in USD and CZK. The account is free and does not ask for a card.

Sdílet:

Written after hours. If this helped, support my work with a coffee ☕