Skip to main content
A prompt change, a new model or a different reasoning effort can quietly make answers worse, and without the right logs you won’t know until users tell you. This page is for developers who want to catch regressions before they ship and have the data to explain what happened when something goes wrong in production.
New to measuring model quality? Metrics and Evaluation in the AI Learning Center introduces the common measures, from benchmarks to human review.
This page covers how to:
  • build a test set from your own examples
  • score answers in ways you can repeat
  • compare models and settings before you switch
  • log what each request did
  • use your logs to debug and to work with support

Build a test set from your own examples

General evaluation benchmarks tell you little about your app. A small set of your own examples tells you a lot.
  • Start with 30 to 100 cases. Take them from real requests (with personal details removed), from your product’s requirements, and from bugs you’ve fixed.
  • Cover the hard parts: short and long inputs, ambiguous questions, questions your app should decline, inputs in other languages, and inputs that try to override your instructions.
  • Write down what a good answer has, not the exact words: the facts it must include, the format it must follow, what it must not do.
  • Keep it in version control next to your prompts, and add a case every time a user reports a bad answer.

Score answers in ways you can repeat

Model output varies from run to run, so score properties, not exact strings.
  • Check with code first. Does the JSON parse and match the schema? Did the tool call name the right tool with valid arguments? Is the answer under the length limit? Did it finish (finish_reason or status)? These checks are cheap and never disagree with themselves.
  • Use a rubric for the rest. For tone, helpfulness and accuracy, have reviewers, or a separate model given a written rubric, score each answer. Spot-check the model’s scores against a person’s before you trust them.
  • Run each case more than once. One run can be lucky. Three to five runs per case show how consistent the answer is.
  • Don’t count on temperature to make runs repeatable. Some models don’t take it, for example Claude 5 models and OpenAI GPT-5 and later models while they reason. The request still runs, and your value is listed in ignored_params. See Sampling parameters.
  • Track cost and time too. Record usage and response time for every case, so a change that improves quality at three times the cost is visible.
Grounded and decision features need their own checks: see Evaluate Before You Ship for grounded answers and Choose thresholds from your own data for System One.

Compare before you switch

Run the whole test set before any change that could affect answers: a new model, a new prompt, a different reasoning effort or output limit, a new tool definition, or a switch between guarded and direct endpoints.
  • Change one thing at a time, so you know what caused a difference.
  • Pin the model in tests and in production, so the model you tested is the model you run. See Choosing, Pinning and Updating Models.
  • Compare side by side. Put the old and new answers for each case next to each other, with scores, usage and time. The Chat Playground is useful for a first look at a few prompts.
  • Decide your bar in advance: for example, no case that passed before may fail, and average cost may not rise by more than 20%.
  • Roll out gradually where you can, and watch the production signals below before moving all traffic.
When a model you use is deprecated, run your test set against the replacement before you change your configuration, since its answers, reasoning and price can differ.

Log what each request did

For every request, log one structured record. Leave out prompt and answer text unless you need it and can protect it. On the direct endpoints, an X-Request-Id you send on the request is returned on the response, so you can use your own ID end to end.
For streams, log the same record when the stream ends, from the headers and the final event, and add whether any output was shown before a failure. See the Observability Checklist.

Watch production

  • Track rates, not single events: error rate by error.name, cut-off rate, content_filter rate, redirect count, cost per feature and response time. A rise matters more than any one request.
  • Alert on model changes. Any X-Gloo-Model-Redirected-From, or a Sunset without it, means a model you use is retiring. See Choosing, Pinning and Updating Models.
  • Reconcile with Studio. The API Usage page shows spend, requests and tokens, filterable by API key. Give each application and environment its own key, so a spike points to a source.
  • Feed problems back into tests. Sample answers regularly, especially refusals, cut-offs and low-rated replies, and add the bad ones to your test set.

Handle retries without hiding problems

Retry only what’s retryable, with backoff and a budget, and log every attempt, not just the last one; a request that succeeds on its third try is a signal. See Error Handling and Retries and the Build a Resilient Client tutorial. When errors persist after retrying, contact support with the trace_id from the error body, and the X-Request-Id on direct endpoints, so the exact request can be traced.

Summary

  • Keep a version-controlled test set of your own examples, and add every reported bad answer to it.
  • Score properties with code first and a rubric second; run each case several times.
  • Change one thing at a time, pin the model, and compare quality, cost and time before you switch.
  • Log model, redirects, ignored_params, usage, how the request ended, timing and request IDs for every request.
  • Watch rates over time, alert on retiring models, and include trace_id or X-Request-Id when you contact support.

Next steps

Error Handling and Retries

Which errors to retry, backoff, budgets and what to log.

Build a Resilient Client

Put retries, failover and logging into code, step by step.

Metrics and Evaluation

The lesson: benchmarks, latency and human evaluation.

Building Trustworthy Grounded Applications

Evaluation for answers grounded in your own content.