By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Your AI service returns 200 OK on every request. The infrastructure is healthy. But the answers are wrong, hallucinated, or refuse to work when they should. HTTP status codes tell you nothing about quality. You need to see inside the system to understand what's actually happening.
Start by distinguishing health from quality. Health is what traditional monitoring measures: latency, time to first token, error rates, queue depth, cache hit rate. These tell you the service is running, not that it's correct.
Cost metrics come next. Track tokens in and out, dollars per request, cost per feature, cost per tenant. As your system scales, you'll find that some features or user segments bleed money in ways that aren't obvious from the code.
Quality is the third layer and the hardest to measure. This includes correctness, whether answers are grounded in retrieved text, whether tool calls use the right arguments, whether guardrails trigger appropriately, and what users actually think.
LAYER 1 HEALTH latency, TTFT, errors, queue depth, cache hit rate
LAYER 2 COST tokens in/out, $ per request, per feature, per tenant
LAYER 3 QUALITY correctness, groundedness, tool-use accuracy,
refusals, guardrail triggers, user feedbackRecord one trace per request. Each trace contains spans for every step: retrieval, every model call, every tool invocation, guardrail checks. When an answer is wrong, the trace shows you where it broke. Did retrieval fail to fetch the right document. Did the model see the document but ignore it. Did a tool return bad data.
This matters because the answer is the output of a pipeline. A wrong answer could come from any stage. Without traces, you're guessing.
Offline evaluation is your regression suite. Start with 30 to 50 realistic questions, including edge cases and adversarial inputs. Run this test set on every change to prompts, models, retrieval settings, or tools. Track scores and cost. When scores drop, you know something broke before it hits users.
Online evaluation samples live traffic and scores it continuously. This catches drift when real usage patterns change or when your data distribution shifts. LLM-as-a-judge scales scoring but is imperfect, so calibrate it against human review on a sample.
User feedback is the ground truth. Thumbs up or down, edits to the answer, escalations to support—these are signals of real failures. Feed them back into your offline test set so you don't regress on the same problem twice.
For retrieval, measure recall or hit rate: did the right chunk appear in the top results. For generation, measure faithfulness: is the answer grounded in the retrieved text or is it invented. For agents, track whether the right tool was called with the right arguments, whether the task completed, and how many steps and cost it took.
Safety metrics matter too. Count injection attempts caught, policy denials, and sensitive-data filters triggered. These are your guardrails working.
Change a prompt, model, chunk size, or tool. Run your offline test set and compare scores and cost to the previous version. If scores improve or stay flat and cost is reasonable, ship to a small slice of traffic—a canary. Watch the online metrics. If they look good, promote to full traffic. If they don't, roll back. Add any new failure mode to your offline test set.
Version everything that can change behavior: prompts, model IDs, retrieval settings, tool schemas. If you cannot say what changed, you cannot explain why quality moved.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.