Evals
Run the same test cases against a tier and read a pass or fail for each: create a suite, add cases, start a run, and poll for results.
An eval suite is a set of test cases you run against a tier. Each case has an
input to send and an expected answer to check the output against. A run
sends every case through chat on the tier you name and records, per case, the
output, whether it passed, and how long it took. Suites live in the workspace
your key names.
Run an eval end to end
The walkthrough below creates a suite, adds two cases, starts a run on saga,
waits for it to finish, and prints each result.
# 1. Create a suite.
curl https://api.cruxy.ai/api/v1/evals/suites \
-H "Authorization: Bearer $CRUXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Capital cities", "slug": "capital-cities" }'
# 2. Add a case. Repeat for each case, with the suite id from step 1.
curl https://api.cruxy.ai/api/v1/evals/suites/$SUITE_ID/cases \
-H "Authorization: Bearer $CRUXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "What is the capital of France? Answer with the city name only.",
"expected": "Paris",
"match_mode": "contains"
}'
# 3. Start a run. It answers 202 at once with status "pending".
curl https://api.cruxy.ai/api/v1/evals/suites/$SUITE_ID/runs \
-H "Authorization: Bearer $CRUXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "saga" }'
# 4. Poll the run, with the run id from step 3, until status is "done" or "failed".
curl https://api.cruxy.ai/api/v1/evals/runs/$RUN_ID \
-H "Authorization: Bearer $CRUXY_API_KEY"
# 5. Read the per-case results.
curl https://api.cruxy.ai/api/v1/evals/runs/$RUN_ID/results \
-H "Authorization: Bearer $CRUXY_API_KEY"const base = 'https://api.cruxy.ai/api/v1'
const headers = {
Authorization: `Bearer ${process.env.CRUXY_API_KEY}`,
'Content-Type': 'application/json',
}
async function call(method: string, path: string, body?: unknown) {
const res = await fetch(`${base}${path}`, {
method,
headers,
body: body === undefined ? undefined : JSON.stringify(body),
})
if (!res.ok) throw new Error(`${method} ${path} failed: ${res.status} ${await res.text()}`)
return res.json()
}
// 1. Create a suite.
const suite = await call('POST', '/evals/suites', { name: 'Capital cities' })
// 2. Add the cases.
const cases = [
{ input: 'What is the capital of France? Answer with the city name only.', expected: 'Paris' },
{ input: 'What is the capital of Japan? Answer with the city name only.', expected: 'Tokyo' },
]
for (const c of cases) {
await call('POST', `/evals/suites/${suite.id}/cases`, { ...c, match_mode: 'contains' })
}
// 3. Start a run on one tier. Every case is a billed completion.
let run = await call('POST', `/evals/suites/${suite.id}/runs`, { model: 'saga' })
// 4. Poll until the run finishes.
while (run.status === 'pending' || run.status === 'running') {
await new Promise((resolve) => setTimeout(resolve, 2000))
run = await call('GET', `/evals/runs/${run.id}`)
console.log(`${run.status}: ${run.completed} of ${run.total_cases} cases`)
}
if (run.status === 'failed') throw new Error(`run failed: ${run.error}`)
console.log(`${run.passed} passed, ${run.failed} failed`)
// 5. Read the per-case results.
const results = await call('GET', `/evals/runs/${run.id}/results`)
for (const r of results.data) {
console.log(r.passed ? 'pass' : 'FAIL', `${r.latency_ms} ms`, r.case_id, r.actual)
}Suites
POST /api/v1/evals/suites creates a suite. name is required, 1 to 128
bytes. slug is an optional stable handle, derived from the name when you
omit it; one already used in the workspace is 409 eval_suite_slug_exists.
prompt_id optionally records the stored prompt the suite tests. It must be a
prompt in the same workspace, or the create is 400 invalid_request. The
link is advisory metadata: a run does not read the prompt.
| Call | Returns |
|---|---|
GET /api/v1/evals/suites | Every suite in the workspace, oldest first, each with its case_count. |
GET /api/v1/evals/suites/{id} | One suite. |
DELETE /api/v1/evals/suites/{id} | Nothing: 204. The suite's cases, runs, and results are deleted with it. |
Cases
POST /api/v1/evals/suites/{id}/cases appends a case. All three fields are
required:
| Field | Meaning |
|---|---|
input | The prompt, sent to the tier verbatim. 1 to 102,400 bytes. |
expected | The reference answer. 1 to 102,400 bytes. |
match_mode | How the output is judged: exact passes when the output equals expected after trimming, and contains passes when the output contains expected. |
Both modes compare text, so write an input that asks for an answer you can
match, such as a single word or a fixed label.
GET /api/v1/evals/suites/{id}/cases lists a suite's cases, oldest first, and
DELETE /api/v1/evals/suites/{id}/cases/{case_id} deletes one.
Runs
POST /api/v1/evals/suites/{id}/runs starts a run against the tier in
model: canto, saga, or epos. auto is refused, because an eval
measures one fixed tier. To compare tiers, start one run per tier on the same
suite.
The call answers 202 at once with the run in status pending, and does not
wait for the cases. A background worker then sends each case through the
standard chat path. Poll GET /api/v1/evals/runs/{id} for progress:
| Field | Meaning |
|---|---|
status | pending, running, done, or failed. |
total_cases | How many cases the run covers. |
completed | How many cases have a result so far. |
passed, failed | The pass and fail split of the completed cases. |
started_at, finished_at | When the run started and finished; each is null until then. |
error | An error message, or null. |
model | The tier the run measures. |
A key whose model allowlist excludes the tier is refused when the run is
started, with 403 model_not_allowed, the same check chat applies.
Results
GET /api/v1/evals/runs/{id}/results lists one result per completed case,
oldest first:
| Field | Meaning |
|---|---|
case_id | The case the result is for. |
actual | The tier's output. |
passed | Whether actual matched the case's expected under its match_mode. |
latency_ms | How long the completion took, in milliseconds. |
Errors
| Status | code | When |
|---|---|---|
400 | invalid_request | A missing or oversized field, or a prompt_id outside the workspace. |
403 | model_not_allowed | The key's model allowlist excludes the tier. |
404 | eval_suite_not_found | The id is not a suite in your workspace. |
404 | eval_case_not_found | The case is not in the suite. |
404 | eval_run_not_found | The id is not a run in your workspace. |
409 | eval_suite_slug_exists | The slug is already used in the workspace. |
See Errors and retries for the envelope and what to retry.
Next steps
- Prompting basics: write the prompt your cases test.
- Choosing a tier: pick the tiers worth comparing.
- Usage and cost: what each case's completion costs.
- API Reference: every eval operation with its exact request and response shape.