Compare Models on One Agent
Overview
You can compare one deployed agent across multiple models by logging the model choice as trace metadata. Confident AI can then run the same online metrics for every trace and build dashboards that filter, split, and trend results by that metadata.
This guide shows the pattern across OpenAI Agents, LangGraph, Vercel AI SDK, and Strands Agents. The core idea is always the same: every request emits a trace, every trace includes a stable model_variant, and every model variant is scored by the same metric collection.
model_variant is the short, human-readable label you pick (gpt-4o, nova-pro, claude-sonnet) — the dimension every dashboard breaks down by. model_id is the exact provider model string behind it. You compare on model_variant and keep model_id for auditability.
Here’s the thing: the model name captured on an LLM span is useful for debugging, but it is often too provider-specific to analyze — and it lives on the span, not the trace. Promoting a stable model_variant to the trace gives every dashboard one clean, product-level dimension to break down, filter, and trend by, even if the underlying provider model ID changes.
This same pattern compares far more than models. Anything you can label on a trace — prompt versions, temperature, retrievers, tool sets — can be compared the exact same way. See Compare Any Parameter to repeat this guide for a different variable.
This guide is for observing model variants from deployed traffic. If you need a controlled comparison where the same dataset is run through multiple models, use Experiments or Arena with one AI Connection configuration per model variant.
What You’ll Build
By the end, you will have:
- A traced agent that records
model_variantandmodel_idon every trace. - A repeatable command to generate comparison traffic for each model variant.
- A metric collection that scores every variant with the same criteria.
- A dashboard that compares quality, trace volume, and latency across variants.
- A clear read of which model wins, not just on one lucky slice of traffic.
Prerequisites
You need a Confident AI project, a project API key, and credentials for whichever model provider your agent calls. For OpenAI-based examples, set OPENAI_API_KEY. For the Strands example, configure AWS credentials with access to the Bedrock model IDs you use.
Install the packages for the integration you are using:
OpenAI Agents
LangGraph
Vercel AI SDK
Strands Agents
Then configure your project and provider credentials for that same integration:
OpenAI Agents
LangGraph
Vercel AI SDK
Strands Agents
For EU projects, point OpenTelemetry export to the EU endpoint:
Use the same CONFIDENT_API_KEY for every model variant you want on the same dashboard. If one service instance writes to a different project, its traces and online eval scores will not appear in the comparison.
Set Up Tracing
Tracing is what feeds every dashboard in this guide. In three steps, you’ll instrument the agent so each request emits a trace tagged with model_variant, attach the metric collection that scores every variant, and verify the data shape before building any widgets.
Instrument the Agent
The most important implementation detail is where you attach metadata. Add model_variant to the trace, not just the LLM span, because dashboards commonly aggregate at the trace level: average trace score, trace count, trace latency, and trace-level online eval results.
Create the traced agent
Create a small agent module that accepts a normalized model variant, resolves it to the provider model ID, runs the agent, and records both names on the current trace.
Each integration below emits the same dashboard keys: model_variant, model_id, agent, agent_version, rollout, and environment.
OpenAI Agents
LangGraph
Vercel AI SDK
Strands Agents
Use OpenAI Agents’ trace context to wrap the run, then call update_current_trace after the agent returns.
Metadata keys can be any string you want — model_variant and model_id are just the ones we use for this example. Here, model_variant is the short, human-readable label you compare on, and model_id is the exact provider value kept for auditability, even if it is noisy. Name your keys whatever is most useful for you.
Run a local trace
Send one request per variant to confirm traces reach Confident AI with the right metadata. Each script takes the variant and the input as positional arguments.
OpenAI Agents
LangGraph
Vercel AI SDK
Strands Agents
Short-lived scripts often exit before traces finish posting. For the DeepEval SDK integrations (OpenAI Agents and LangGraph), set CONFIDENT_TRACE_FLUSH=1 to flush traces synchronously before the process exits. Strands exports spans in real time and the Vercel AI SDK tracer flushes on shutdown, so they don’t need it.
Done ✅. You now have at least one trace per model variant.
Create Metrics
Use the same metric collection for every model variant so each is scored against identical criteria. Your project’s evaluation model — the LLM judge — is shared across every collection, so the judge itself is already consistent. The trap is scoring gpt-4o-mini and gpt-4o with different collections: you would be trending scores from two different rubrics, so the dashboard is no longer an apples-to-apples comparison.
Create a metric collection
Open Project > Metrics > Collections, create a collection named Agent Quality, and add trace-level metrics that match the agent’s job.
For a support agent, a strong starting collection is:
- Task Completion for whether the answer solved the user’s request.
- Answer Relevancy for whether the response stayed focused.
- A custom G-Eval metric for your product-specific standard, such as “support policy compliance” or “escalation quality”.
Online evals only run referenceless metrics during tracing. Metrics that require expected_output, expected_tools, or other reference data are better for offline test runs, Arena, or Experiments.
Attach the collection in code
The earlier examples attach Agent Quality in the integration-specific trace context. That means every trace receives the same online eval collection, even though the exact API differs by framework.
OpenAI Agents
LangGraph
Vercel AI SDK
Strands Agents
OpenAI Agents sets the trace-level collection with update_current_trace:
If you prefer not to set the collection in code, configure Evaluation Rules in Project Settings. Use a rule filter such as metadata.agent = support-agent or metadata.rollout = model-comparison, then apply the same Agent Quality collection to matching traces.
Generate enough scored traces
Dashboards are only useful once there is enough data to compare. Run each variant across a few prompts so the metric collection scores a batch of traces.
OpenAI Agents
LangGraph
Vercel AI SDK
Strands Agents
This local batch is enough to populate the dashboard. For a real model decision, compare over production traffic across a stable time range.
Verify the Traces
Before building dashboards, verify that the data shape is right. It is much easier to fix metadata and metric-collection names before you create five widgets around them.
Open the Observatory
In Confident AI, go to Observatory and filter for your agent or rollout:
metadata.agent = support-agentmetadata.rollout = model-comparisonmetadata.model_variant = gpt-4ofor OpenAI-based examples, ormetadata.model_variant = nova-profor Strands
Inspect one trace
Open a trace and confirm four things:
- The trace input and output are populated.
- The trace metadata includes
model_variant,model_id,agent_version, androllout. - The LLM span captured the provider model details from your integration.
- The trace has online eval results from
Agent Quality, or shows a clear metric error you can fix.
Create the Dashboard
The traces and scores from the previous step feed the dashboard. Build it either way — pick Platform to click through the Confident AI UI, or CLI to run a reproducible script against the Dashboards API. Your choice sticks across every step below, so you only pick once.
The examples use the OpenAI variants gpt-4o-mini, gpt-4o, and gpt-4.1. For Strands, swap in nova-lite, nova-pro, and claude-sonnet.
Create the dashboard
Platform
CLI
In Confident AI, create the dashboard from the sidebar:
- Open Dashboards.
- Click New Dashboard.
- Set Name to
Model Variant Comparison. - Set Description to
Compares support-agent quality, volume, and latency by metadata.model_variant. - Keep Private off to share it with the project, or on for a personal draft.
- Click Create.
Add quality by model
Platform
CLI
Click Add widget and create a time-series widget that breaks down quality by model_variant:
This is the main comparison chart: which model scores higher over time under the same metric collection?
Add trace volume
Platform
CLI
Add a second time-series widget for traffic volume, so you don’t over-trust a model that only handled a few easy requests:
Interpret Results
A model that scores higher is only the better choice if it also handled enough traffic to trust and kept latency acceptable. Read the three widgets together:
- Quality: Is the candidate’s average score higher over a meaningful date range?
- Volume: Does each variant have enough traces to trust the result? Low-volume variants can win by chance.
- Latency: Is P90 latency still acceptable for your product?
Compare Any Parameter
Here’s the key insight: nothing in this guide is actually model-specific. model_variant is just the metadata key every dashboard breaks down by. Swap it for any variable you want to A/B and the exact same workflow — one agent, one metric collection, three widgets — still applies. You’re not comparing models, you’re comparing whatever you label on the trace.
To compare something else, repeat the guide and change only two things:
- The metadata key you attach on the trace. Log
prompt_version(ortemperature,retriever, …) instead of, or alongside,model_variant. - The dimension each widget breaks down by. Point the same dashboard filters at the new key.
Everything else stays identical. The new key is attached exactly like model_variant — as trace metadata:
Common parameters teams compare this way:
- Prompt versions —
prompt_version: v3vsv4. - Decoding settings —
temperature: 0.2vs0.7. - Retrieval strategy —
retriever: bm25vshybrid, orchunk_size: 512vs1024. - Tool sets —
toolset: minimalvsfull. - Agent versions —
agent_version: v2vsv3.
Attach several keys on the same trace (model_variant, prompt_version, temperature) and build one dashboard per dimension from the same traffic — no new instrumentation required. Just change one variable at a time when you want the dashboard to attribute a difference cleanly.
Chart Any Measure
And just like the breakdown dimension is swappable, so is the measure each widget plots. This guide charts quality (AVG_SCORE), trace volume (COUNT), and P90 latency (P90_LATENCY) — but that’s only three of many. Add a line with a different aggregation and you have a new comparison from the exact same traffic.
Measures you can break down by any dimension:
- Quality —
AVG_SCORE,PASS_RATE,FAILURE_RATE, orAVG_RATINGfor any metric in your collection. - Latency —
AVG_LATENCY,P50_LATENCY,P90_LATENCY,P99_LATENCY. - Cost & tokens —
TOTAL_COST,AVG_COST,AVG_COST_PER_USER,INPUT_TOKENS,OUTPUT_TOKENS,TOTAL_TOKENS. - Volume & users —
COUNT,UNIQUE_USERS,UNIQUE_THREADS. - Reliability —
ERROR_COUNT,ERROR_RATE.
Combine both ideas: break any measure down by any metadata key. “Average cost by prompt_version” or “P99 latency by model_variant” is the same widget with two fields changed.
Best Practices
These are optional deep-dives once the core comparison is working.
- Compare one thing at a time. If the prompt, tools, retriever, and model all change at once, the dashboard cannot tell you what caused the difference.
- Keep metadata names consistent. Dashboards depend on exact metadata keys, so do not alternate between
model,model_name, andmodel_variant. - Separate product labels from provider IDs. Use
model_variantfor the decision people understand andmodel_idfor exact reproducibility. - Use enough traffic before deciding. Low-volume variants can look better or worse by chance. Compare over a stable time range.
- Watch quality and operations together. A model with a higher score but much worse latency may not be the better choice.
What to Track
The dashboard depends on consistent metadata. Start with these keys:
model_variant— the comparison dimension, such asnova-liteorclaude-sonnet.model_id— the exact provider model ID used for the request.agent— the stable application or agent name, such assupport-agent.agent_version— the deployed agent version.rollout— the rollout, canary, or A/B test name.environment— production, staging, development, or testing.
Keep metadata values boring and predictable. model_variant="nova-pro" is easier to query than model_variant="Nova Pro - July canary (fast)". Put temporary rollout context in rollout, not in the model name.
Online evals observe the model used by each trace. They do not automatically send the same request to every model unless your agent does that routing itself. For one-input-to-every-model comparisons, use Experiments or Arena.
Rollout Patterns
Three common ways to route traffic across models while comparing them:
- Shadow compare — send production traffic to the current model and run a copy through candidate models off the user-facing path. Log shadow traces with
rollout=shadow-model-compare. High signal, but every request may call multiple models. - Canary release — send a small percentage of real traffic to the candidate and label it
rollout=canary-v3. The simplest production rollout; watch trace volume, since a 5% canary looks noisy until it has enough traffic. - Segment routing — route a model to a specific segment such as internal users, one tenant, or one task type, and add metadata for that segment. Useful when the best model depends on the request.
Troubleshooting
My dashboard has no model_variant breakdown.
Open a trace and check whether metadata.model_variant exists on the trace.
If it only appears on an LLM span, move the value to update_current_trace.
Dashboards can only break down trace-level data by metadata that exists on
the trace.
Online eval scores are missing.
Confirm that the metric collection name in code exactly matches the
collection name in Confident AI. Then check that the trace has the
parameters required by the metrics, usually input and output for
referenceless trace-level metrics.
One model looks much better but has tiny traffic.
Add a trace-count widget next to the quality widget and compare over a longer time range. Low-volume variants can win by chance, especially if the router sent them easier requests.
The raw provider model ID keeps changing.
Keep model_variant stable and put the exact provider value in model_id.
The dashboard should usually break down by model_variant, while model_id
is there for debugging and audit trails.
Next Steps
Use this setup to compare model variants under one agent, then roll out the winner once quality, volume, and latency all look healthy.
Trace OpenAI Agents workflows with agent, LLM, tool, handoff, and guardrail spans.
Trace LangGraph agents with callback handlers, trace metadata, and online evals.
Instrument AI SDK generations with Confident AI tracing and trace context.
Instrument Strands agents with OpenTelemetry, online evals, and trace metadata.
Build widgets from metric data, traces, filters, and metadata breakdowns.
Score traces and spans as production traffic is ingested.
Add metadata to traces, spans, and threads for filtering and analysis.