Prompt
LLM app latency token cost alerts
Latest observation
Nov 20, 2026
OpenAI APIWeb search: off
To set up latency and token-cost alerts for an LLM app, track a few core metrics and alert on thresholds, rate changes, and anomalies.
What to measure
Latency
- End-to-end request latency
- Time to first token (TTFT)
- Tokens/sec
- P50 / P95 / P99 latency
- Latency by model, endpoint, tenant, prompt type
Cost
- Input tokens
- Output tokens
- Total tokens per request
- Cost per request
- Daily / hourly spend
- Cost by model, user, tenant, route
Good alert types
1. Absolute threshold alerts
Examples:
- P95 latency > 3s for 10 min
- TTFT > 1.5s for 10 min
- Daily token spend > $500
- Average cost/request > $0.05
2. Spike alerts
Examples:
- Tokens/request increases by 30% vs 7-day baseline
- P95 latency jumps 2x vs previous hour
- Output tokens unusually high for a route
3. Budget alerts
Examples:
- 50%, 80%, 90%, 100% of monthly budget reached
- Per-tenant budget exceeded
- Per-feature budget exceeded
4. Error-adjacent alerts
Examples:
- High latency plus high timeout rate
- Cost rises while quality metrics stay flat
- Retry rate spikes, causing token inflation
Practical alert rules
A simple starting set:
- P95 latency > 2s for 15 min
- P99 latency > 5s for 10 min
- TTFT > 1s for 15 min
- Tokens/request > baseline + 25%
- Daily spend > 80% of budget
- Cost/request > baseline + 20%
- 5xx or timeout rate > 2%
- Retry rate > 5%
Recommended dashboards
Create panels for:
- Request count
- P50/P95/P99 latency
- TTFT
- Input/output/total tokens
- Cost per request
- Spend over time
- Top expensive prompts/tenants/users
- Retries, timeouts, and failures
Alerting best practices
- Alert on percentiles, not just averages
- Use baseline comparisons to avoid noisy alerts
- Separate alerts by model, route, and tenant
- Include context in the alert: model, endpoint, sample requests, token counts, recent deploys
- Add rate limits / budget caps to prevent runaway spend
- Suppress alerts during known traffic bursts or scheduled load tests
If you want a concrete implementation
You can instrument your app with:
- OpenTelemetry for traces/metrics
- Prometheus + Alertmanager
- Grafana dashboards
- Or a managed observability tool
For token accounting, log per request:
- prompt tokens
- completion tokens
- total tokens
- model name
- latency
- status/error
- tenant/user/route
- estimated cost
If you want, I can give you:
- a sample Prometheus alert rules file,
- a Grafana dashboard layout, or
- a Python/TypeScript instrumentation example.