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"

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.

CallReturns
GET /api/v1/evals/suitesEvery 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:

FieldMeaning
inputThe prompt, sent to the tier verbatim. 1 to 102,400 bytes.
expectedThe reference answer. 1 to 102,400 bytes.
match_modeHow 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:

FieldMeaning
statuspending, running, done, or failed.
total_casesHow many cases the run covers.
completedHow many cases have a result so far.
passed, failedThe pass and fail split of the completed cases.
started_at, finished_atWhen the run started and finished; each is null until then.
errorAn error message, or null.
modelThe 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:

FieldMeaning
case_idThe case the result is for.
actualThe tier's output.
passedWhether actual matched the case's expected under its match_mode.
latency_msHow long the completion took, in milliseconds.

Errors

StatuscodeWhen
400invalid_requestA missing or oversized field, or a prompt_id outside the workspace.
403model_not_allowedThe key's model allowlist excludes the tier.
404eval_suite_not_foundThe id is not a suite in your workspace.
404eval_case_not_foundThe case is not in the suite.
404eval_run_not_foundThe id is not a run in your workspace.
409eval_suite_slug_existsThe slug is already used in the workspace.

See Errors and retries for the envelope and what to retry.

Next steps

Was this page helpful?