input, output, expected, and metadata, and returns a metric. There are two kinds: code scorers, which you write as a function, and LLM-as-a-judge scorers, which grade the output with a model.
Code scorers
Any function is a scorer. The metric takes the function’s name.- Python
- TypeScript
Adding a threshold
Wrap the function inScorer.code to give a numeric metric a pass mark, so the platform can mark each score as passing or failing and compare runs.
- Python
- TypeScript
keyidentifies the scorer. Use the samekeyin Python and TypeScript for the same scorer.thresholdanddirectiondecide whether a numeric score passes.- The metric takes the scorer’s name. If you return a
Scorewith a different name, give it that scorer’s name too — otherwise the threshold can’t be matched to it.
LLM-as-a-judge
For a judge, the model and the prompt are the scorer. Write the prompt with{{input}}, {{output}}, and {{expected}} placeholders, filled in per case.
- Python
- TypeScript
rubric="…" is a shorthand when you only need a single grading instruction.
Building the prompt from the case
To fill in your own placeholders, pass a function that returns the template values. It returns variables for the prompt, never a score.- Python
- TypeScript
complete= (Python) / complete: (TypeScript) — a function taking the model and messages and returning a string — to stub the model call, so judges run in tests and CI without an API key.
What a scorer can return
- a boolean or number,
- a
Score—Score(name, value, comment=None, metadata=None), - a list of
Scores, or a{metric: value}map, for a scorer that emits several metrics, - a
DeferredScore— a score awaiting human or async review. It’s recorded as pending, never as a zero.
Next steps
Running Evals
Point a task and your scorers at a dataset and run the eval.
Reading Results
Per-metric averages, pass rates, and case status.