Evaluators
Create evaluator
Creates a new evaluator with an initial version.
Payload Requirements
- The evaluator name must be unique within the given space.
- type (top-level) selects the evaluator kind: TEMPLATE or CODE. With TEMPLATE, provide version.template_config. With CODE, provide version.code_config — where code_config.type is MANAGED or CUSTOM (a separate discriminator within code_config, independent of the top-level type: CODE).
- For template evaluators: version.template_config.name is the eval column name; must match ^[a-zA-Z0-9_\s\-&()]+$.
- For template evaluators: version.template_config.template is the prompt template; use {variable} for placeholders (f-string format, e.g. {input}, {output}).
- For template evaluators: version.template_config.classification_choices is required and maps choice labels to numeric scores (e.g. {"relevant": 1, "irrelevant": 0}).
- For code evaluators: see CodeConfig — managed evaluators (code_config.type: MANAGED) use managed_evaluator and variables; custom evaluators (code_config.type: CUSTOM) use code, optional imports, and variables.
- System-managed fields (id, created_at, updated_at, created_by_user_id) are rejected on input.
Valid example (template evaluator)
{
"name": "Hallucination Detector",
"space_id": "U3BhY2U6MTpWNEth",
"type": "TEMPLATE",
"version": {
"commit_message": "Initial version",
"template_config": {
"name": "hallucination",
"template": "Given the input: {input}\nand the output: {output}\nIs the output a hallucination?",
"include_explanations": true,
"use_function_calling_if_available": true,
"classification_choices": {"hallucinated": 0, "factual": 1},
"llm_config": {
"ai_integration_id": "TGxtSW50ZWdyYXRpb246MTI6YUJjRA==",
"model_name": "gpt-4o",
"invocation_parameters": {"temperature": 0},
"provider_parameters": {}
}
}
}
}
Invalid example (type/config mismatch — TEMPLATE type with code_config)
{
"name": "Bad Evaluator",
"space_id": "U3BhY2U6MTpWNEth",
"type": "TEMPLATE",
"version": {
"commit_message": "Wrong config",
"code_config": {
"type": "CUSTOM",
"name": "my_eval",
"code": "class Evaluator: ...",
"variables": ["input"]
}
}
}
<Note>This endpoint is in beta, read more here.</Note>
post/v2/evaluators
Request body
Response
Returns an evaluator with a resolved version