DEVELOPER DOCS

REST API

Eval

On this page

Managed evaluation: build datasets from production traces, define rubrics that say what a good answer looks like, run them, and read a per-case and aggregate result. On top of that sit a release gate (ship / warn / block), a human review queue with judge calibration, and online scoring of live traffic with a canary.

All routes live under /v1/observ/orgs/{org}/workspaces/{ws}/eval, take the optional ?project=<slug> like every other observ read, and return the usual { "data": …, "meta": { "request_id": … } } envelope.

Feature flag. Every route answers 409 eval_disabled until eval_enabled is on for the deployment. That is a product state, not a failure — hide or grey the Eval surface rather than raising an error.

Note the code, not just the status: dataset_frozen is also a 409 on these routes, and treating a frozen dataset as "feature off" would blank a working screen.

Criterion kinds and the BYOK dependency

A rubric is a list of criteria. Which kind each one is decides whether it costs you anything to run:

KindNeeds a judge model?Notes
binary➖Deterministic pass/fail
regex➖pattern is required
json_valid➖Output must parse
scale✅prompt is required; scores 1–5
llm✅prompt is required

scale and llm call a judge model on the org's own BYOK LLM credential (the one at /v1/orgs/{org}/llm-credentials). Without a credential those criteria come back skipped with a skip_reason, and the deterministic criteria in the same rubric still score. Surface that rather than failing the run — a rubric is usually a mix, and the deterministic half is still useful.

Eval judge usage is billed to the customer's key and shows in the spend views as engine=eval.


Rubrics

HTTP
GET  /eval/rubrics     (viewer)  → data: EvalRubric[]
POST /eval/rubrics     (admin)   → data: EvalRubric
TypeScript
type Criterion = {
  key: string;                 // ^[a-z0-9][a-z0-9_-]*$, ≤64, unique in the rubric
  kind: "binary"|"scale"|"regex"|"json_valid"|"llm";
  prompt?: string;             // required for scale | llm
  pattern?: string;            // required for regex
  weight?: number;             // ≥0, default 1
};
type EvalRubric = {
  id: string; workspace_id: string; name: string;
  mode: "pointwise"|"pairwise";   // default pointwise
  criteria: Criterion[];          // 1..50
  judge_model?: string|null; version?: number;
};

mode decides how a case is scored: pointwise judges each answer on its own, pairwise compares two and records whether the verdict survived swapping their order (see CaseResult.order).

Python

Python
rubric = evigauge.post(f"{root}/eval/rubrics", json={
    "name": "Refund reply quality",
    "mode": "pointwise",
    "judge_model": "claude-sonnet-4-5",
    "criteria": [
        {"key": "cites_policy", "kind": "regex", "pattern": r"(policy|clause)\s+\d+", "weight": 1.5},
        {"key": "valid_json", "kind": "json_valid"},
        {"key": "answers_the_question", "kind": "llm", "weight": 2,
         "prompt": "Does the reply answer what the customer actually asked?"},
    ],
})
print(rubric["id"], "v", rubric["version"])

Datasets

HTTP
GET  /eval/datasets                  (viewer) → data: EvalDataset[]
POST /eval/datasets                  (admin)  → data: EvalDataset
POST /eval/datasets/{id}/curate      (admin)  → data: { added, candidates }
POST /eval/datasets/{id}/pin         (admin)
POST /eval/datasets/{id}/freeze      (admin)
GET  /eval/datasets/{id}/export.csv  (viewer) → text/csv
TypeScript
type EvalDataset = {
  id:string; workspace_id:string; project_id?:string|null; name:string;
  version:number; source:"curated"|"pinned"|"mixed"; slice:Record<string,unknown>;
  holdout_pct:number; frozen:boolean; item_count:number; created_at:string;
};

Two ways to fill a set

Curate pulls matching production traces in bulk. The scan is bounded server-side and floored at 90 days, so a broad slice returns a sample rather than everything:

jsonc
POST /eval/datasets/{id}/curate
{ "slice": { "prompt_version": "refund@2026-11-02", "gen_ai_model": "claude-sonnet-4-5",
             "reliability_grade": "C", "since": "2026-10-01", "until": "2026-11-06" },
  "limit": 500 }        // ≤ 2000
→ { "added": 184, "candidates": 612 }

Pin adds one trace — the "I just read a good/bad answer, keep it" action. start_time is part of the key the item is stored under, so a pin without it lands in the wrong partition:

jsonc
POST /eval/datasets/{id}/pin
{ "trace_id": "tr_4d10", "start_time": "2026-11-05T09:17:00Z", "expected": {} }

Freezing

POST /eval/datasets/{id}/freeze makes the set immutable. Afterwards curate, pin and any other write return 409 dataset_frozen. Freeze before a run you intend to compare against later — a set that keeps changing makes two runs non-comparable without either of them looking wrong.

holdout_pct keeps a share of items aside so a rubric tuned on the set can still be checked against cases it was not tuned on.


Runs

HTTP
POST /eval/runs                  (admin)  → data: { run_id }
GET  /eval/runs                  (viewer) → data: EvalRun[]
GET  /eval/runs/{id}             (viewer) → data: EvalRun
GET  /eval/runs/{id}/results     (viewer) → data: CaseResult[]
GET  /eval/runs/{id}/results.csv (viewer) → text/csv
TypeScript
type EvalRun = {
  id:string; dataset_id:string; rubric_id:string; prompt_version?:string|null;
  status:"pending"|"running"|"done"|"failed";
  summary?: { n:number; pass_rate:number; mean_score:number;
              by_criterion:Record<string,{pass_rate:number;mean_score:number}>;
              skipped_items?:number } | null;
  created_at:string; finished_at?:string|null;
};
type CaseResult = {
  trace_id:string; criterion:string; score:number; passed:boolean;
  order?:string|null;        // pairwise: "stable" | "unstable"
  skipped:boolean; skip_reason?:string;
};

POST /eval/runs is async — it returns a run_id before any scoring has happened. Poll GET /eval/runs/{id} roughly every 1.5s while status is pending or running.

⚠ pass_rate is per CASE, n is per ITEM

A case is one item scored against one criterion. A rubric with five criteria produces five cases per item, so for any multi-criterion rubric:

code
pass_rate × n  ≠  the number of items that passed

Label the headline "case pass-rate". Never render it as "N of n passed" — that is a different and smaller number, and the mistake survives review because both figures look plausible. A per-item verdict is what the gate provides.

The list endpoint promises no ordering. Sort by created_at yourself.


Release gate

Compare a candidate run against a baseline over the same dataset, both done, and get a decision.

HTTP
POST /eval/gate        (admin)  → data: GateVerdict   (+ gate_id)
GET  /eval/gate/{id}   (viewer) → data: GateVerdict
GET  /eval/gate        (viewer) → data: GateVerdict[]   (?limit, ?project)
TypeScript
type GateVerdict = {
  decision: "ship" | "warn" | "block" | "insufficient_data";
  reasons: string[];                 // written to be shown verbatim
  quality: {
    paired_n: number;                // items×criteria present in BOTH runs
    candidate_pass_rate: number; candidate_lb: number;   // Wilson lower bound
    baseline_pass_rate: number;
    mcnemar: { b:number; c:number; statistic:number; p_value:number; significant:boolean };
    unpaired?: number;
  };
  cost: { candidate:any; baseline:any; cost_delta_pct:number|null;
          latency_delta_pct:number|null; evaluable:boolean } | null;
  flips: { trace_id:string; criterion:string }[];
  by_criterion: Record<string, any>;
  gate_id?: string;
};

Errors: 400 gate_mismatch (different datasets) · 400 run_not_done · 404 cross-workspace. Both 400s name a fixable input problem, so surface them rather than a generic failure.

⚠ McNemar is two-sided

b counts regressions (baseline passed → candidate failed) and c counts improvements. significant: true with c > b means the candidate got better.

Only treat it as a regression when significant && b > c. Rendering "significant" as bad news on its own turns a win into a warning.

⚠ insufficient_data is not a block

It means the two runs did not overlap on enough paired cases to say anything. Colour and word it neutrally; nothing failed.

The cost arm has three states, and only one is a result:

costMeaningRender
nullNeither run had a prompt_versionHide the panel
evaluable: falseNothing comparable in production yet"Not evaluated" — not a pass
evaluable: trueReal deltasShow the percentages

The gate costs from ~30 days of production history, so a brand-new candidate normally comes back evaluable: false. That is expected. For a fresh version, use the canary instead — it costs from the traffic it scores.

flips is the actionable part: exactly the cases that passed on the baseline and fail on the candidate. Link every trace_id to the trace view.


Review queue and calibration

The trust layer: label the cases the judge was least sure about, then measure how far the judge and your reviewers actually agree.

HTTP
GET  /eval/runs/{id}/review-queue?limit=   (viewer) → data: QueueItem[]
POST /eval/labels                          (viewer)
GET  /eval/runs/{id}/labels                (viewer) → data: Label[]
POST /eval/runs/{id}/calibrate             (admin)  → data: CalibrationReport
GET  /eval/runs/{id}/calibration           (viewer) → data: CalibrationReport
TypeScript
type QueueItem = { trace_id:string; criterion:string; score:number;
                   passed:boolean; uncertainty:number };

type Kappa = { n:number; po:number; pe:number; kappa:number|null; degenerate:boolean };
type CalibrationReport = {
  status: "ok" | "insufficient_labels" | "degenerate";
  judge_human: Kappa;            // judge vs your reviewers
  human_human: Kappa | null;     // inter-annotator, when ≥2 reviewers overlap
  n_labels:number; n_annotators:number;
  judge_drift:boolean;
  raw_agreement:number;
};

The queue is ordered by uncertainty — closeness to the decision boundary — so the first items are where a human verdict changes the most. The annotator is the caller; there is no annotator parameter.

POST /eval/labels takes { run_id, trace_id, criterion, label, note? } with label ∈ "pass" | "fail" | "unsure". A bad trace or criterion returns 400 label_unknown_case.

GET …/calibration 404s until the run has been calibrated at least once — treat that as "not calibrated yet", not an error.

⚠ Never render a null κ as 0.0

kappa is nullable on purpose. null means the statistic could not be computed — most often because the judge gave one verdict to everything, which makes expected agreement 1 and κ undefined. 0.0 means the judge agrees no better than chance.

Those are opposite claims. Map the states explicitly:

StateShow
status: "insufficient_labels""Need more labels" + n_labels
status: "degenerate" or judge_human.degenerate"Cannot certify"
kappa === null"Cannot certify"
otherwisethe number

judge_drift: true means judge↔human agreement is under the floor: the grades are uncalibrated and a block from the gate should be discounted until the judge prompt or model is fixed and the run is recalibrated. Surface it prominently — it is the signal that makes the gate's verdict unreliable.

When human_human is high and judge_human is low, the judge is the problem. When both are low, the rubric itself is ambiguous.


Online scoring

Continuous scoring of a sample of live traffic.

HTTP
GET /eval/online/config                     (viewer) → data: OnlineConfig
PUT /eval/online/config                     (admin)  → data: OnlineConfig
GET /eval/online/snapshots?since=<unix_s>   (viewer) → data: OnlineSnapshot[]
TypeScript
type OnlineConfig   = { rubric_id:string; sample_rate:number; enabled:boolean };
type OnlineSnapshot = { window_start:string; n:number; pass_rate:number;
                        mean_score:number; snapshot_at:string };

Off by default per workspace. It samples rather than scoring everything because each judged case costs a call on the customer's own key.

⚠ Gaps are gaps, not zeroes

A window with no scorable traffic writes no snapshot at all. Position points by timestamp and break the line across a missing window.

Joining across the gap — or plotting pass_rate: 0 for it — shows a quality collapse that never happened.


Canary

Score a live sample of two prompt versions side by side.

HTTP
POST /eval/canary   (admin)  → data: CanaryVerdict
TypeScript
type CanaryVerdict = {
  decision: "ship" | "hold" | "insufficient_data";
  reasons: string[];
  candidate: { n:number; pass_rate:number; lb:number };   // lb = Wilson lower bound
  baseline:  { n:number; pass_rate:number };
  window_hours:number;
  cost: {
    candidate:{cost:number;latency:number}; baseline:{cost:number;latency:number};
    cost_delta_pct:number|null; latency_delta_pct:number|null;
    evaluable:boolean; latency_evaluable:boolean; reason?:string;
  } | null;
};

Body: { candidate_version, baseline_version, rubric_id, window_hours? }.

The verdict is quality AND cost. A candidate that holds quality but regresses on cost or latency comes back hold, so a UI that shows only the pass-rate will look broken — it will display "Hold" above an unchanged quality figure with no explanation.

⚠ Two independent honesty flags

evaluable covers cost and latency_evaluable covers latency, and they move separately. Check each metric's own flag before showing its number. Sharing one flag lets an unmeasured latency ride in on a measured cost and print a figure that was never computed.

When a flag is false show "not evaluated" with reason — never 0% and never "within limits".

Unlike the gate's cost arm, the canary costs from each version's own sampled traces, so it works for a candidate with no production history.

This endpoint scores live traffic on demand, so the request is slow by design (bounded, admin-only). Allow a long timeout and show progress — a client that treats the wait as a hang will cancel a request that was going to succeed.


CSV export

HTTP
GET /eval/datasets/{id}/export.csv   (viewer)   trace_id,start_time,is_holdout,expected
GET /eval/runs/{id}/results.csv      (viewer)   trace_id,criterion,score,passed,order,skipped

Both return text/csv as an attachment, formula-injection-safe server-side. They need the workspace header and a bearer token like any other call, so fetch them server-side and hand the body to the browser rather than pointing an anchor at the URL.

skip_reason is not in the results CSV yet. It is available on GET /eval/runs/{id}/results, so a skipped row in the CSV shows skipped=true with no explanation.


End to end

import time
root = "/v1/observ/orgs/{org}/workspaces/{ws}"

# 1. A standard, and a set to measure against it.
rubric = evigauge.post(f"{root}/eval/rubrics", json={...})
ds = evigauge.post(f"{root}/eval/datasets",
                   json={"name": "Refund replies", "source": "curated", "slice": {}})
evigauge.post(f"{root}/eval/datasets/{ds['id']}/curate",
              json={"slice": {"gen_ai_model": "claude-sonnet-4-5"}, "limit": 500})
evigauge.post(f"{root}/eval/datasets/{ds['id']}/freeze")   # comparable from here on

# 2. Score it, and wait.
run_id = evigauge.post(f"{root}/eval/runs",
                       json={"dataset_id": ds["id"], "rubric_id": rubric["id"],
                             "prompt_version": "refund@2026-11-06"})["run_id"]
while True:
    run = evigauge.get(f"{root}/eval/runs/{run_id}")
    if run["status"] in ("done", "failed"):
        break
    time.sleep(1.5)
if run["status"] == "failed":
    raise SystemExit("eval run failed")

s = run["summary"]
print(f"case pass-rate {s['pass_rate']:.1%} over {s['n']} items")   # NOT s['pass_rate']*s['n']

# 3. Is it safe to ship?
gate = evigauge.post(f"{root}/eval/gate",
                     json={"candidate_run_id": run_id, "baseline_run_id": prev_run_id})
q = gate["quality"]
regressed = q["mcnemar"]["significant"] and q["mcnemar"]["b"] > q["mcnemar"]["c"]
print(gate["decision"], "— regression" if regressed else "")
for f in gate["flips"]:
    print("  regressed:", f["trace_id"], f["criterion"])