Skip to content

Evals and red teaming

Test models, prompts and agents on the traffic you already serve

Turn real requests and agent sessions into test sets, compare models item by item, stop a pull request that makes answers worse, grade live traffic, check your AI judge against people, and probe a model for weaknesses before it ships. All from the Admin UI or the API.

Request a free 30-day Enterprise trial

We email you a trial license key for your own servers. No payment details.

Read the evals docs (opens in a new tab)

Opens the documentation in a new tab.

EnterpriseEvals need a license that includes evals. Without it, saved schedules and online scoring pause and pick up again when the license returns.
The eval loopYour traffic, meaning logs, agent sessions and files, becomes a dataset of test items with expected answers. A run sends every item to every model you pick. Scorers grade the results with exact checks, judge models or your own scorer. A gate compares the run with the trusted baseline and passes or fails the pull request. Scored items also go to human review, where people label answers pass or fail without seeing the judge, and calibration shows how often the judge agrees. Labelled items export to a golden dataset that feeds back into your datasets. After launch, schedules rerun datasets with alerts and online scoring grades a share of live answers, and sampled answers can fill review queues.Your trafficLogs, agent sessions and files1. DatasetTest items and expected answers2. RunEvery item on every model you pick3. ScoreExact checks, judges or your own4. GatePull request passes or failsagainst the trusted baselineHuman reviewPeople label answers without seeingthe judge. Labelled items become agolden dataset.After launchSchedules, alerts and onlinescoring of live answers
Real traffic becomes a test set, every change is scored against it, and people check that the judge agrees with them. A pull request that makes answers worse fails before it merges.

01

Datasets from what you already serve

Write test items by hand, import a JSONL or CSV file, sample real requests from the logs, or turn whole agent sessions into items. A dataset from logs can keep the recorded answers as the expected answers, so it works as a regression test against what production returned.

Example

Turn last week's support chats into a test set, then check whether a cheaper model answers them as well.

Terms used here:

  • Sample by date, team, key, model or status, at random or the most recent
  • Sessions become one item each, with the whole conversation, tool calls and tool results
  • Every item runs on every model you pick, through the gateway's own router, so eval traffic is logged and priced like other traffic, passes the same guardrails, and stays within the caller's budgets and rate limits
  • Each run reports pass rate, mean score, latency and cost per model, and every item shows the output, score and reason
  • Render items through a managed prompt version, from the environment you pick, to test a prompt change before it ships, and let a passed run be the only way that version is promoted to production
  • No traffic yet? Generate a synthetic dataset from your documents, with a critic model checking every question
  • Every edit that changes the items stores a new version of the dataset, and a run records which version it scored, so a result can be read back against exactly the items it saw
Read about datasets from what you already serve in the docs (opens in a new tab)

Sample a dataset from production logs

curl http://localhost:4000/eval/datasets/from_logs \
  -H "Authorization: Bearer sk-your-admin-key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "support prompts, last week",
    "filters": {
      "start": "2026-10-08T00:00:00Z",
      "end": "2026-10-15T00:00:00Z",
      "teams": ["support"],
      "status": "success"
    },
    "sample": {"size": 200, "strategy": "random"},
    "include_outputs_as_expected": true
  }'

Run it every night with a regression alert

curl http://localhost:4000/eval/schedules \
  -H "Authorization: Bearer sk-your-admin-key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "nightly support regression",
    "dataset_id": "6c1f...",
    "models": ["gpt-5.6", "claude-sonnet-5-5"],
    "scorer": {"type": "g_eval", "judge_model": "gpt-5.6",
               "criteria": "The answer resolves the issue."},
    "cron": "0 3 * * *",
    "timezone": "Europe/Berlin",
    "alert": {"min_pass_rate": 0.85, "regression_threshold": 0.05}
  }'

Datasets from logs need the gateway to store request and response bodies in its spend logs.

02

Conversations and agents

Some answers only make sense across a whole conversation. Replay a conversation turn by turn, run an agent with canned tool results so no real tool is ever called, or score a conversation exactly as it was logged.

Example

Check that your support bot still asks for the order number before it issues a refund, across the whole conversation.

  • Replay mode sends each user turn and scores the replies in context
  • Agent mode lets the model call tools, answered by fixtures you write, up to a step limit you set
  • Logged mode scores conversations as they happened, with no new model calls
  • Each result keeps the full transcript, the number of steps and the number of tool calls
Read about conversations and agents in the docs (opens in a new tab)

03

Scorers

Exact checks need no model and cost nothing. Judged metrics use a judge model your gateway serves, a pass threshold you set, and keep a reason for every score. Transcript scorers grade whole conversations and tool use.

Example

Fail any answer that is not valid JSON, and ask a judge whether the rest actually answer the question.

Terms used here: ,

  • Exact match, contains, regex and JSON schema
  • A rubric you write, scored by a judge model, against an expected answer or over a whole conversation, with the judge shown both answers under random names when it compares them
  • Answer relevancy, faithfulness to retrieved context, hallucination, bias, toxicity, summarization and JSON correctness
  • Contextual precision, recall and relevancy for retrieval
  • Tool call correctness and argument match, computed by the gateway with no judge cost
  • Task completion, turn relevancy, conversation completeness, knowledge retention, role adherence and turn faithfulness for whole conversations
  • Plan quality, plan adherence, step efficiency, tool use and MCP use for agents
  • Non-advice, misuse, PII leakage and role violation for safety, and a decision graph you define
  • Citation faithfulness and a RAGAS score for answers that cite retrieved documents
  • Agent loop detection and tool permission checks that need no judge and cost nothing
  • Image judges that show a vision model the pictures in an answer, and voice checks that measure recorded calls with no judge
Read about scorers in the docs (opens in a new tab)

04

Your own scorers

Register a scorer that runs on your own HTTPS server. The gateway signs every request so your server can check it came from your gateway, and the docs show the exact request and reply format to build it from.

Example

Grade answers against your house style rules, on a server you run, with your own code.

  • Signed requests, timeouts, retries and a limit on how many run at once
  • Scorer addresses must be public HTTPS unless you allow an internal host, and items under a zero data retention or no-training policy are never sent
  • A documented request and reply format, in any language your team uses
Read about your own scorers in the docs (opens in a new tab)

05

Compare runs and try things in the playground

Put up to four runs side by side, item by item, and filter to what got worse, what got better or what stayed the same. The playground tries a prompt on a few items and models while you wait, and stores nothing.

Example

See exactly which 12 questions got worse after switching models, and why the judge marked them down.

Terms used here:

  • Score, latency and cost changes for every item, against a baseline run you choose
  • Comparing reads stored results only, so it costs nothing
  • The playground runs up to 30 item and model pairs, at most 20 items and 3 models, and shows the exact messages each model received
Read about compare runs and try things in the playground in the docs (opens in a new tab)
An eval run that tested four models on a ticket triage test set. A table shows the pass rate, mean score, mean latency and cost of each model, with the best model marked.
An eval run puts models side by side on your own test set, with the cost of each. Admin UI with demo data.

06

Gate pull requests

Run an eval on every pull request and compare it with the last trusted run from your main branch. A CI key can only start eval runs and read their results. The spanwayctl evals gate command turns the verdict into an exit code and a comment on the pull request.

Example

A pull request that makes answers worse fails its check before anyone merges it.

  • Thresholds for pass rate, mean score, error rate, drops against the baseline, cost increase and new failures, checked for each model
  • Only runs started by an admin, or by a baseline writer key on the branches you list, become trusted baselines. Keep that key where only protected branches can read it
  • Every eval call, CI runs included, stays within the caller's budgets and rate limits and passes your guardrails
  • Works from any CI pipeline that can run the command line tool
Read about gate pull requests in the docs (opens in a new tab)

07

Evals as code

Keep evals in your repository next to the prompts they test. One command runs all your eval files and, in watch mode, runs them again every time you save a prompt. Evals can also be ordinary pytest tests that fail when the gateway's verdict says the answers got worse.

Example

Save a prompt edit and see a minute later whether the refund answers still pass.

  • spanwayctl evals run takes several eval files at once and exits with the worst result
  • Watch mode reruns on every save of an eval file, a prompt file or a folder you name, and Ctrl-C cancels the run in flight
  • The Python client's pytest plugin runs an eval from a test and fails it on a failed verdict, so a regression fails the pull request
  • The same gateway verdict everywhere, in a terminal, a test, a CI job and the Admin UI
Read about evals as code in the docs (opens in a new tab)

08

Keep checking after launch

Put a dataset on a schedule with an alert, so a drop after a new model snapshot or a prompt edit shows up the next morning. Online scoring grades a sample of real answers as they happen, after the reply has gone back, so it never slows a request down.

Example

Grade 5% of real answers for relevance every day, and get an alert when the pass rate drops.

Terms used here:

  • Schedules run on a cron in your time zone, and each run starts exactly once even with several replicas
  • Regression alerts go to Slack, Microsoft Teams or a webhook when the pass rate falls under a floor or drops since the last run
  • Online scoring rules pick traffic by model group, team, key or tag, sample a share of it and use one to five scorers
  • A daily judge budget caps what online scoring may spend
  • When an online rule's pass rate drops, the regression lands in the alerts inbox, where your team acknowledges, assigns and resolves it
  • Online scoring respects zero data retention and code traffic rules, so a judge never sees what it should not
  • Shadow evaluation verdicts appear next to your offline runs
Read about keep checking after launch in the docs (opens in a new tab)

09

Change a judge without guessing

Before an online scoring rule goes live, run it on real logged answers and see the scores, the judge's reasons and what it will cost each day. Every save keeps a numbered version you can restore, a backfill grades last week's traffic so a new rule has history from day one, and you can see how often the judge agrees with your reviewers.

Example

Try a stricter judge on ten real support answers, see it would cost 3 dollars a day, and restore the old one when a model update makes it too harsh.

Terms used here: ,

  • Try a rule on up to 10 logged requests, agent traces or typed answers, with nothing saved and a spending cap on the test
  • Preview the requests scored and the judge cost per day from the last week of matching traffic
  • See why any request was or was not sampled, the same answer on every replica
  • Every change keeps a numbered version, and every score records the version that produced it
  • Backfill past traffic with the same sampling live scoring uses, skipping what was already scored
  • Agreement with human reviewers per judge version, with a suggested threshold
Read about change a judge without guessing in the docs (opens in a new tab)

10

Human review and judge calibration

An AI judge is only useful if it agrees with the people who know what a good answer looks like. Reviewers you pick label answers pass or fail, one at a time, without seeing the judge's verdict. The calibration report shows how often each judge agrees with them, and labelled items export to a golden dataset.

Example

Two support leads mark 100 answers pass or fail, and you see that the AI judge agrees with them 9 times out of 10.

Terms used here:

  • Queues filled from eval results, sampled production answers or shadow traffic
  • Labels are blind, and two reviewers never get the same item at once
  • An assignment board shares items out evenly and takes them back from anyone who is away
  • Blind review hides the reference answer and shuffles the order for each reviewer
  • Reviewer agreement shows whose labels drift and which items are disputed
  • Production items are skipped when their request required zero data retention
  • Retention and erasure reach review items and labels
Read about human review and judge calibration in the docs (opens in a new tab)

11

Ratings from the people using your app

Your app sends what a user thought of an answer, a score from 0 to 1, a label or a comment, against the gateway's id for that request. Ratings filter datasets from logs and review queues, so the answers people disliked are the ones you test and review first. Ratings follow the request's team, and with a retention period set they never outlive the spend logs.

Example

curl -X POST "$GATEWAY/eval/feedback" -H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" -d '{"request_id": "req-123", "score": 0, "label": "wrong answer"}'

  • Any key can rate the requests of its own team, never another team's
  • Datasets from logs and review queues can keep only rated, or only poorly rated, requests
  • Admin viewers list ratings and proxy admins delete them on the Evals page, Feedback tab
  • A data subject request exports and erases the ratings of an end user
Read about ratings from the people using your app in the docs (opens in a new tab)

12

Red teaming

Point the attack engine at one model and choose what to probe for. One gateway model writes the attacks, single-turn or multi-turn, and another judges whether the target held up.

Example

Before launch, try 20 attacks that ask your bot to reveal its instructions, and see which ones worked.

Terms used here:

  • Results show an overall pass rate, broken down by vulnerability and by attack, weakest first
  • Every finding keeps the attack prompt, the reply and the judge's reason, so you can reproduce and fix it
  • Attacks pass through your guardrails like real requests, and one a guardrail blocks counts as defended
  • A catalogue lists every vulnerability and attack technique with a description
  • Start a run from a preset for the OWASP Top 10, the NIST AI RMF, MITRE ATLAS or the EU AI Act, or send prompts you supply from the Aegis and BeaverTails safety datasets
  • Results also group by the OWASP Top 10 for LLMs 2025, the OWASP Top 10 for Agentic Applications 2026, the NIST AI Risk Management Framework, MITRE ATLAS and the EU AI Act, so one finding shows up under every category that lists it
  • Every attack and every run carries a CVSS score from 0 to 10 with a severity word, weighted by what the vulnerability type exposes, so a leaked credential or customer record rates high or critical, and the compliance report checks that a recent red team run completed, withstood attacks and has no high or critical finding
Read about red teaming in the docs (opens in a new tab)
  • Bias
  • Toxicity
  • PII leakage
  • Prompt leakage
  • SQL and shell injection
  • SSRF
  • Excessive agency
  • Role-based access abuse

13

Access and audit

Proxy admins create and run evals, admin viewers can read them, and a custom role can be granted either. Creating, changing, cancelling or deleting a dataset, run, schedule, rule or review queue is written to the audit log with the user who did it.

Run it yourself. Start today.

Start the gateway, track and cap spend on every request, and add SSO, audit logs and custom SLAs when it goes org-wide.

Request the free install guide

Starter is free with no license key. A short form emails hello@spanway.ai from your mail app and we reply with the install guide for your setup.

Contact sales

Opens a short form that emails sales@spanway.ai from your mail app. No commitment.