Evaluations

Evaluations let you run a fixed batch of content through a moderation policy and see how it is handled. Re-run the same set after you change rules, filters, or LLM settings to see what improved or drifted.

Use them from the dashboard (Moderation → Configuration → Evaluations) or from the server-side SDKs. The dashboard is the easiest way to create sets, watch a run, and compare results. The API is the same surface the dashboard calls, so you can automate evaluations from CI or your own tooling.

Evaluations are a batch re-run of saved content. They are not the same as Test Policy on a policy editor, which is a one-off check of a single sample against the policy you are editing.

Concepts

TermMeaning
Evaluation setA named, saved batch of up to 1000 items. The text is frozen so later runs are comparable.
RunOne execution of every item in the set against live moderation. Runs are asynchronous: you start one, then poll until it finishes.
BaselineThe first completed run of a set. Later runs are scored against it (or against seeded production outcomes, see Replay).
ReplayA set with no config_key. Each item is re-run under the policy it was originally moderated under.
Scored rowA row that can receive a pass/fail verdict (it has expected labels/action, or it is compared to a previous run). Unscored rows only record what the policy did.

Replay vs a single policy

When you create a set you pick how rows are executed:

  • A specific policy. Every item runs against that policy's current configuration.
  • Replay. Omit config_key. Seeded items keep the policy they originally ran under. Deleted policies are skipped for those rows.

Pasted (hand-written) content has no original policy, so it always needs a policy selected.

How scoring works

  1. The first completed run is the baseline. It has no pass/fail metrics of its own.
  2. Later runs compare each row's labels and recommended action to the baseline (or, for replay sets seeded from production, to the original production outcome stored on the row).
  3. Rows with no expectations (empty labels and empty recommended action) are unscored. The run still records actual labels and action so you can inspect them, but they are excluded from pass/fail totals.

A row fails when labels differ (label_mismatch), the recommended action differs (action_mismatch), the provider errors (provider_error), or the row's policy no longer exists (policy_not_found).

Billing and retention

Each item in a run executes real moderation calls (LLM, NLP, image checks, and so on) at standard rates, the same as production traffic.

Each set keeps the last 10 completed runs. Starting another after that deletes the oldest run and its per-row results. In-flight runs are not deleted.

Using the dashboard

  1. Open Moderation → Configuration → Evaluations.
  2. Click Create evaluation.
    • Give the set a name.
    • Choose a policy, or Replay to re-run each item under its original policy.
    • Sample your newest moderated production content (up to 1000 items), or paste content (one item per line).
  3. Open the set and click Run evaluation. Confirm the dialog: this spends real moderation usage.
  4. When the run completes, compare it to the baseline or to another run. Filter to drifted rows, inspect a row's labels and recommended action, and export results as CSV.

You can also open Evaluations already filtered to a policy from that policy's page.

Creating, running, and deleting evaluations requires full access to the app's moderation configuration privilege. Read-only users can view sets and results.

API

These methods are server-side only. They are not available from client-side SDKs.

Every run is billed as production moderation. Poll the run until status is terminal (completed, error, or cancelled). There is no cancel method. A run stuck in pending/running for more than about 15 minutes is marked error so a new run can start.

Create an evaluation set

POST /api/v2/moderation/policy_tests/sets

Provide either rows or seed, not both. Names are unique per app.

The example below samples the newest production content for a policy. To paste items instead, pass rows (each with a text field). To replay each item under its original policy, omit config_key.

response = client.moderation().create_policy_test_set(
    name="Hate-speech sample",
    config_key="chat:messaging",
    seed={"labels": [], "limit": 100},
)

Request parameters

NameRequiredTypeDescription
nameyesstringDisplay name. Unique within the app.
config_keynostringPolicy to run every row against. Omit for replay.
teamnostringTeam scope for the policy (multi-tenancy).
modenostringlabels or check. If omitted, the server picks labels when the Labels API is enabled for the org, otherwise check.
seedone ofobjectSample newest production content. Labels-mode sets sample stored label results; check-mode sets sample reviewed AI-text review-queue items. Mutually exclusive with rows.
rowsone ofarrayExplicit items, max 1000. Each text is required, max 20,000 characters. Mutually exclusive with seed.

seed fields:

NameRequiredTypeDescription
limityesnumberHow many items to sample, newest first. 1 to 1000.
labelsnostring[]Only sample records that carry any of these labels. Empty (or omitted) samples everything. Max 20.

Row fields (when using rows, and also returned on seeded sets):

NameTypeDescription
textstringContent to moderate.
labelsstring[]Expected labels (optional).
recommended_actionstringExpected action (optional).
policystringOriginal policy key. Used on replay when config_key is empty.
content_typestringWhen username, labels-mode runs dispatch through the username classification path.

Response

NameTypeDescription
setobjectThe created set.

If seeding matches no production data, the request fails. Broaden labels or moderate more content first.

List evaluation sets

GET /api/v2/moderation/policy_tests/sets

Each set in sets may include last_run so you can show last-run status and pass rate without a second request.

response = client.moderation().list_policy_test_sets(limit=50)

Request parameters

NameRequiredTypeDescription
limitnonumberPage size. Default is the store default, max 200.
offsetnonumberOffset for pagination.

Response

NameTypeDescription
setsarrayEvaluation sets for the app.

Get an evaluation set

GET /api/v2/moderation/policy_tests/sets/{id}

Returns set (including rows), recent_runs (newest first, capped at 10), and baseline_run_id once the first run has completed.

response = client.moderation().get_policy_test_set("pts_...")

Request parameters

NameRequiredTypeDescription
idyesstringThe evaluation set to retrieve.

Response

NameTypeDescription
setobjectThe set, including rows.
recent_runsarrayRetained run history, newest first.
baseline_run_idstringEarliest completed run. Absent until the first run finishes.

Delete an evaluation set

DELETE /api/v2/moderation/policy_tests/sets/{id}

Cascades to runs and results. Fails if a run is still pending or running.

client.moderation().delete_policy_test_set("pts_...")

Request parameters

NameRequiredTypeDescription
idyesstringThe evaluation set to delete.

Start a run

POST /api/v2/moderation/policy_tests/sets/{id}/runs

The body is empty. Only one run may be in progress per set. When a new run is created, the oldest terminal runs beyond the 10-run cap are deleted.

response = client.moderation().start_policy_test_run("pts_...")

Request parameters

NameRequiredTypeDescription
idyesstringThe evaluation set to execute.

Response

NameTypeDescription
runobjectThe new run, typically with status: "pending".

Get a run (and results)

GET /api/v2/moderation/policy_tests/runs/{id}

Poll this while status is pending or running. rows_completed / rows_total track progress. Per-row results are omitted until the run is terminal, so polling stays cheap.

response = client.moderation().get_policy_test_run("ptr_...")

Request parameters

NameRequiredTypeDescription
idyesstringThe run to retrieve.

Response

NameTypeDescription
runobjectThe run, including progress and metrics when available.
resultsarrayPer-row results. Present only once the run has finished.

Run object

FieldTypeDescription
idstringRun id.
set_idstringParent set.
statusstringpending, running, completed, error, or cancelled.
config_keystringPolicy snapshot used for this run.
config_updated_atstringWhen that policy was last updated, if it exists.
rows_totalnumberItems in the set.
rows_completednumberItems processed so far.
metricsobjectSet on non-baseline completed runs. Pass/fail totals plus per-label drift.
error_messagestringPresent when status is error.
triggered_bystringWho started the run.
started_atstringWhen the worker picked up the run.
completed_atstringWhen it reached a terminal status.

metrics.totals:

FieldDescription
rowsAll rows.
scoredRows included in pass/fail.
unscoredRows recorded without a verdict.
passedScored rows that matched the baseline/seed.
failedScored rows that drifted or errored.

metrics.by_label maps each label to { same, changed }. changed counts rows where that label was added or dropped versus the baseline. Rows where the label was absent in both runs are not counted.

Result object (terminal runs)

FieldTypeDescription
row_indexnumberIndex in the set.
message_textstringThe item's text.
expected_labelsstring[]Baseline or seeded labels.
expected_actionstringBaseline or seeded recommended action.
actual_labelsstring[]Labels this run produced.
actual_actionstringRecommended action this run produced.
scoredbooleanWhether the row received a verdict.
passedbooleantrue/false when scored; null when not.
failure_reasonstringlabel_mismatch, action_mismatch, provider_error, or policy_not_found.
severitystringAI-text severity from the provider, display only. Not part of pass/fail.

Compare two runs client-side: fetch both, join on row_index.

  1. Create a set from recent production traffic for the policy you are about to change.
  2. Run it once to capture a baseline (or rely on seeded production outcomes for replay).
  3. Change the policy, rules, or filters.
  4. Run the same set again and inspect drifted rows before you roll the change out further.