How do you monitor LLM latency, errors and cost in production?
You monitor LLM latency, errors and cost in production by recording every request at one point, tracking a small set of metrics per project, key and model, alerting on thresholds, and tracing multi-step workflows so a slow or expensive step can be found. In FastRouter, alerts cover response time, time to first token, throughput, error count, error rate, token consumption, spend and total requests, and tracing records latency, tokens and cost for each span.
Last updated
Key facts
- FastRouter alerts cover nine metrics: Response Time, Time to First Token, Throughput, Error Count, Error Rate, Token Consumption, Daily Spend, Monthly Spend and Total Requests.
- Response Time and Time to First Token are measured as medians (p50).
- Alerts use a static value or a percentage change, and are evaluated every 5, 15 or 30 minutes, hourly or daily, in UTC.
- Tracing follows the W3C Trace Context standard and needs only a traceparent header, with no SDK.
- Pricing lists distributed tracing and alert rules from the Pro plan upward.
What is the general approach to monitoring LLMs in production?
The general approach is to measure at a single point that sees every request, keep three groups of signals (performance, reliability, and usage and cost), break them down by workload, and alert on both fixed limits and sudden changes. Traces add the per-step detail that aggregate metrics cannot show.
- Measure in one place: a gateway in front of the providers records the same fields for every model.
- Track errors as a count and as a rate, because a rate hides volume and a count hides proportion.
- Slice by project, key, model and tag so a regression can be tied to one workload.
Which LLM metrics are worth tracking?
Track latency, time to first token, throughput, errors, tokens, spend and request volume. These are the metrics FastRouter's alerts page lists, and each one answers a different operational question. The metric names are the ones on the alerts page, so they can be used directly when creating alerts; the definitions are from FastRouter's alerts documentation.
| Metric | What it measures | What it tells you |
|---|---|---|
| Response Time | Median (p50) end-to-end latency from request receipt to response completion, in ms | Whether calls as a whole are getting slower |
| Time to First Token | Median (p50) time until the first response token begins streaming, in ms | How long users wait before streamed output starts |
| Throughput | Median request throughput for streaming responses, in requests per second | Whether streaming traffic is being served at the expected pace |
| Error Count | Total failed requests within the evaluation window | The absolute size of a failure |
| Error Rate | Percentage of requests that failed | The share of traffic affected, independent of volume |
| Token Consumption | Total tokens consumed, input plus output | Usage growth, and prompts or outputs that are getting longer |
| Daily Spend and Monthly Spend | Cumulative spend for the current day or month, reset on a UTC schedule | Whether cost is on track against a budget |
| Total Requests | Total number of API requests | Traffic drops that may indicate an outage, or unexpected surges |
How do you set up LLM monitoring in FastRouter?
In FastRouter you tag requests so usage can be sliced by feature or environment, send a traceparent header on multi-step workflows, create alerts on latency, errors and spend scoped to the projects, keys and models that matter, choose who is notified, and review the weekly Insights run for cost recommendations. Pricing lists tracing and alert rules from the Pro plan.
- Tag requests by feature, customer or environment. Add a request_tags array to chat completion requests. Dynamic tags can be flat or path-style, appear as a dashboard filter, and are stored in activity-log metadata.
curl --location 'https://api.fastrouter.ai/api/v1/chat/completions' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer API-KEY' \ --data '{ "model": "openai/gpt-4o-mini", "stream": false, "messages": [ { "role": "user", "content": "What are some famous tourist attractions in London?" } ], "temperature": 0.0, "request_tags": ["UK/London", "Europe"] }' - Send a traceparent header on multi-step workflows. Generate one W3C traceparent value and reuse it on every request in an agent run, chat session or batch of parallel calls. All calls that share the trace_id appear as a single trace with ordered spans.
- Create latency, error and spend alerts. Create alerts on metrics such as Response Time, Error Rate and Daily Spend. Scope each to All or specific projects, API keys and models, choose a static value or a percentage change, set a Critical threshold, which is required, optionally add a Warning threshold for early notice, and pick an evaluation interval.
- Choose who is notified. Send notifications to email addresses, organization owners or project members, or to Slack, Flock or a custom webhook. Alerts move between OK and Firing as conditions change.
- Review weekly Insights. Insights runs a read-only weekly analysis of each qualifying Key + Model scope and publishes cost recommendations with sampled requests, savings math and a confidence rating.
How should alert thresholds and intervals be chosen?
Use a static value where the limit is already known, such as a latency target or a daily budget, and a percentage change where the concern is sudden movement against a baseline. Evaluate fast-moving reliability metrics more often than slow-moving spend metrics, and scope production and staging alerts separately.
- Percentage change compares a metric with the previous period, or with the same time 1 hour, day, week or month ago.
- FastRouter's alerts documentation recommends 5 minutes for Error Rate and Error Count, 15 to 30 minutes for Response Time and Time to First Token, and hourly or daily for spend.
- FastRouter suggests a Warning threshold at about 50 to 70 percent of the Critical threshold.
- If an evaluation window has no data, the alert keeps its current state.
How does tracing find the slow or expensive step?
Tracing groups the calls of one workflow into a single trace of ordered spans. In FastRouter each span records latency, token usage, cost and the full request and response, so the slowest span and the span with the most tokens can be read directly from the trace.
The traceparent header has the form version-trace_id-parent_id-flags, where trace_id is 32 hex characters and parent_id is 16. Optional headers set a readable span name (x-span-name), a custom span ID (x-span-id) or a different trace ID (x-trace-id).
How do you keep LLM cost under review over time?
Alerts catch spend that crosses a line. A periodic review finds structural savings. FastRouter Insights does this weekly: once a Key + Model scope has passed 1,000 text-generation requests in the previous 7 days, the next run can publish recommendations for prompt caching, Flex tier, model swaps and prompt compression.
Prompt caching and Flex tier insights are free and on by default. Model swap and prompt compression belong to Advanced cost insights, a billed opt-in. Insights never edits requests, prompts or routes.
Sources
Where the statements about FastRouter on this page come from.