API Reference
Cohort-aware agent evaluation API. Import suites from YAML, run scenarios against live agent endpoints, compare against per-cohort baselines.
All API requests require an API key passed in the X-API-Key header. Keys are created via the dashboard at /app → Settings → API Keys.
curl -H "X-API-Key: ak_live_xxxx" "https://assaykit.polsia.app/api/suites"
| Header | Value | Description |
|---|---|---|
| X-API-Key | string | Your API key. Passed as ak_live_xxxx. Required for all /api/* routes except /api/keys. |
GET /api/runs/:id until status is completed.
Cohorts are string tags that let you maintain separate baselines for different agent segments. The same scenario suite can be evaluated against multiple cohorts — e.g., enterprise agents vs. SMB agents — with independent quality floors.
Cohort names are arbitrary strings. Use whatever labels your team recognizes. Null/empty cohort represents the suite-level "all agents" baseline.
cohort, AssayKit looks for an active baseline for that same (suite, cohort) pair. If found, every result in that run gets a drift_score computed against the cohort baseline. Baselines are created separately per cohort via POST /api/suites/:id/baselines.
Import or update a test suite from YAML or JSON. Accepts application/json or text/yaml. If a suite with the same name already exists, it is updated in place — this makes the import idempotent for CI pipelines.
cohort field sets the default cohort for runs created against this suite's scenarios.# my-suite.yaml name: agent-v2-evaluation description: End-to-end quality checks for the v2 agent pipeline cohort: enterprise # ← default cohort for runs using this suite threshold: 0.75 # suite-level pass threshold (0–1, default 0.70) scenarios: - name: customer-support_routes_correctly prompt: A customer asks: "I was charged twice this month." Route to billing support. expected_output: The agent should route to the billing department, not general support. target_url: https://api.youragent.com/chat target_headers: Authorization: Bearer your-agent-token request_body: model: gpt-4o threshold: 0.80 # optional per-scenario override - name: refund_request_acknowledges_amount prompt: A customer requests a $49.99 refund. Confirm the amount in your response. expected_output: The agent must echo "$49.99" — partial or rounded amounts fail. target_url: https://api.youragent.com/chat target_headers: Authorization: Bearer your-agent-token request_body: model: gpt-4o
{
"suite_id": 42,
"suite_name": "agent-v2-evaluation",
"scenario_count": 2
}
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | required | Unique suite name. Used as idempotency key — existing suite with same name is updated, not duplicated. |
| description | string | optional | Human-readable description of this suite's purpose. |
| cohort | string | optional | Default cohort tag for runs using this suite. Stored at import time; used to suggest the cohort when creating runs. Does not affect which baseline is active — that is controlled by the run's own cohort field. |
| threshold | number | optional | Suite-level pass threshold. 0–1 (e.g., 0.75) or 0–100 (e.g., 75). Default: 0.70. Per-scenario thresholds override this. |
| scenarios | array | required | Array of scenario objects. At least one is required. |
Create and execute a test run. Execution is asynchronous — the endpoint returns immediately with a run_id and status running. Poll GET /api/runs/:id to check progress.
cohort to score results against a cohort-specific baseline.{
"name": "enterprise-v2.5-release-candidate",
"suite_id": 42,
"cohort": "enterprise", // ← cohort tag for baseline matching
"scenario_ids": null // omit → run all scenarios in suite
}
{
"run_id": 137,
"status": "running",
"total": 2
}
| Field | Type | Description |
|---|---|---|
| name | string | Optional run name. Defaults to timestamp string. |
| suite_id | integer | Run all scenarios in this suite. If omitted, runs all scenarios across all suites. |
| scenario_ids | int[] | Run only these specific scenario IDs. Takes precedence over suite_id. |
| cohort | string | Cohort tag for this run. AssayKit looks for an active baseline matching (suite_id, cohort). If found, each result gets a drift_score. Pass null to use the suite-level baseline. |
Returns the run record with all results and a computed drift summary. If the run was created with a cohort that has an active baseline, the drift object shows per-scenario regressions.
{
"id": 137,
"name": "enterprise-v2.5-release-candidate",
"suite_id": 42,
"cohort": "enterprise", // ← cohort this run was tagged with
"status": "completed",
"avg_score": 81.4,
"pass_rate": 0.72,
"passed": 5,
"failed": 2,
"total_scenarios": 7,
"created_at": "2026-05-17T13:00:00Z",
"completed_at": "2026-05-17T13:00:47Z",
"drift": { // ← present only when cohort baseline exists
"baseline_id": 89,
"scenarios_compared": 7,
"regressions": [
{
"scenario_id": 14,
"scenario_name": "customer_support_routes_correctly",
"drift_score": -12.3, // current score 12.3 pts below baseline
"score": 68.1,
"baseline_id": 89
}
],
"improvements": [
{
"scenario_id": 17,
"scenario_name": "refund_request_acknowledges_amount",
"drift_score": +3.1,
"score": 88.4,
"baseline_id": 89
}
],
"has_regressions": true
},
"results": [
{
"id": 551,
"scenario_id": 14,
"scenario_name": "customer_support_routes_correctly",
"actual_output": "I'll connect you with a representative...",
"score": 68.1,
"passed": false,
"pass_threshold": 80,
"drift_score": -12.3, // negative = below cohort baseline
"baseline_id": 89,
"latency_ms": 1247,
"error": null,
"score_breakdown": {
"semantic_similarity": 0.62,
"lexical_overlap": 0.28,
"length_score": 0.88
}
}
]
}
List recent runs, optionally filtered by suite. To filter runs by cohort tag, include ?cohort=enterprise — returns all runs with that cohort, newest first.
suite_id // filter by suite cohort // filter by cohort tag (e.g. cohort=enterprise) limit // max results, default 20, max 100
Capture a completed run's scores as the active baseline for a cohort. This "pins" the current quality level. Subsequent runs with a matching cohort tag compare against this baseline and receive drift_score values on each result.
{
"run_id": 137,
"cohort": "enterprise" // omit → creates suite-level baseline (null cohort)
}
{
"id": 89,
"suite_id": 42,
"cohort": "enterprise",
"run_id": 137,
"scenario_count": 7,
"created_at": "2026-05-17T13:05:00Z"
}
cohort value each time.
List all baselines ever created for a suite. The most recent active baseline for each cohort is marked with is_active: true. Baseline rows include the run_id they were captured from and the run name.
[ { "id": 89, "suite_id": 42, "cohort_name": "enterprise", "run_id": 137, "run_name": "enterprise-v2.4.1-baseline", "is_active": true, // active for "enterprise" cohort "snapshot_scores": [...], "created_at": "2026-05-17T13:05:00Z" }, { "id": 72, "suite_id": 42, "cohort_name": "smb", "run_id": 98, "run_name": "smb-v1-baseline", "is_active": true, // active for "smb" cohort "snapshot_scores": [...], "created_at": "2026-05-10T09:00:00Z" } ]
cohort_name field on each baseline row lets you find the right baseline. There is no server-side ?cohort= filter on this endpoint — all baselines for a suite are returned so the full cohort picture is always visible.
Drift is computed as drift_score = current_score - baseline_score per scenario. A negative drift_score means regression vs. the cohort baseline. The run-level drift object aggregates this into a summary.
| Field | Type | Description |
|---|---|---|
| drift.baseline_id | integer | ID of the active baseline used for comparison. |
| drift.scenarios_compared | integer | Number of scenarios that had a cohort baseline entry to compare against. |
| drift.regressions | object[] | Scenarios where drift_score < -5 (more than 5 points below baseline). Each entry has scenario_id, scenario_name, drift_score, score, baseline_id. |
| drift.improvements | object[] | Scenarios where drift_score > 0 (above baseline). Same shape as regressions. |
| drift.has_regressions | boolean | true if regressions array is non-empty. Convenient boolean for CI checks. |
| result.drift_score | number|null | Per-scenario drift. null when no cohort baseline is active for this (suite, cohort) pair. |
| result.baseline_id | integer|null | Which baseline was used to compute this drift_score. null if no baseline was found. |
Each scenario result is scored with a hybrid model:
| Component | Weight | Description |
|---|---|---|
| Semantic similarity | 60% | Cosine similarity between OpenAI text-embedding-3-small embeddings of the expected output and actual output. Falls back to lexical-only if embeddings are unavailable. |
| Lexical overlap | 25% | Token-level Jaccard similarity between expected and actual output. Captures keyword/phrase matching the embeddings might miss. |
| Length reasonableness | 15% | Penalizes outputs that are significantly shorter or longer than expected. Ratio-based: min(actual_len, expected_len) / max(actual_len, expected_len). |
score_breakdown is included in every result object, so you can see exactly why a score came in low. Check semantic_similarity vs lexical_overlap to diagnose the failure mode.
Export a suite as YAML or JSON. Use ?format=yaml (or ?format=yml) to get a file you can commit to git. The export does not include cohort — that is a run-level concern, not a suite definition property.
name: agent-v2-evaluation threshold: 0.75 scenarios: - name: customer_support_routes_correctly prompt: A customer asks: "I was charged twice this month." Route to billing support. expected_output: The agent should route to the billing department, not general support. target_url: https://api.youragent.com/chat target_headers: Authorization: Bearer your-agent-token request_body: model: gpt-4o threshold: 0.80 - name: refund_request_acknowledges_amount prompt: A customer requests a $49.99 refund. Confirm the amount in your response. expected_output: The agent must echo "$49.99" — partial or rounded amounts fail. target_url: https://api.youragent.com/chat target_headers: Authorization: Bearer your-agent-token request_body: model: gpt-4o