Create Metric
POSThttps://api.confident-ai.com/v2/metrics
Creates a custom metric in your Confident AI project and returns it. A GEVAL metric scores against criteria or evaluationSteps; a DAG metric needs algorithm set to DAG and a dag.
curl -X POST "https://api.confident-ai.com/v2/metrics" \
-H "CONFIDENT_API_KEY: <PROJECT-API-KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "Correctness",
"multiTurn": false,
"criteria": "Determine if the actual output is correct based on the expected output.",
"evaluationSteps": [
"Compare the actual output with the expected output.",
"Penalise any factual contradiction."
],
"evaluationParams": [
"actualOutput",
"expectedOutput"
],
"rubric": [
{
"scoreRange": [
8,
10
],
"expectedOutcome": "The answer is factually correct and complete."
}
],
"algorithm": "DEFAULT",
"dag": {
"nodes": {
"root": {
"type": "BinaryJudgementNode",
"criteria": "Does the actual output answer the input?",
"evaluation_params": [
"input",
"actual_output"
],
"children": [
"pass",
"fail"
]
},
"pass": {
"type": "VerdictNode",
"verdict": true,
"score": 10
},
"fail": {
"type": "VerdictNode",
"verdict": false,
"score": 0
}
}
}
}'{
"success": true,
"data": {
"id": "<METRIC-ID>",
"name": "Correctness",
"algorithm": "DEFAULT",
"criteria": "Determine if the actual output is correct based on the expected output.",
"evaluationSteps": null,
"rubric": [
{
"scoreRange": [
8,
10
],
"expectedOutcome": "The answer is factually correct and complete."
}
],
"dag": {
"nodes": {
"root": {
"type": "BinaryJudgementNode",
"criteria": "Does the actual output answer the input?",
"evaluation_params": [
"input",
"actual_output"
],
"children": [
"pass",
"fail"
]
},
"pass": {
"type": "VerdictNode",
"verdict": true,
"score": 10
},
"fail": {
"type": "VerdictNode",
"verdict": false,
"score": 0
}
}
},
"multiTurn": false,
"requiredParameters": [
"actualOutput",
"expectedOutput"
]
},
"deprecated": false
}Headers
CONFIDENT_API_KEYstringRequiredThe API key of your Confident AI project.
Request body
namestringRequiredThe name of the metric, unique within your project.
multiTurnbooleanThis is true when the metric evaluates conversations rather than single test cases. It decides which
evaluationParamsare valid and cannot be changed later.criteriastringThe criteria the metric scores against. A GEVAL metric needs
criteriaorevaluationSteps.evaluationStepslist of stringsThe steps the metric follows to score, as an alternative to
criteria.evaluationParamslist of enumsThe test case fields the metric evaluates. A single-turn metric needs at least one, and every field must match
multiTurn.Show 14 enum valuesHide 14 enum values
inputactualOutputexpectedOutputcontextexpectedToolscontentrolescenarioexpectedOutcometurnstoolsCalledretrievalContextmetadatatags
rubriclist of objectsScore ranges that anchor how the metric scores.
Show 2 propertiesHide 2 properties
scoreRangelist of anyRequiredThe inclusive start and end of the score range this outcome describes, each between 0 and 10, with the start no greater than the end.
expectedOutcomestringRequiredWhat a response scoring in this range looks like.
algorithmenumThe algorithm the metric is evaluated with. GEVAL scores against criteria or evaluation steps, DAG walks a decision graph, CODE runs your own code, and DEFAULT is a built-in metric.
Show 4 enum valuesHide 4 enum values
DEFAULTDAGGEVALCODE
dagobjectThe decision graph of a DAG metric. It is validated on write, and metric references are resolved against the metrics in your project.
Show 1 propertyHide 1 property
nodesobjectRequiredThe graph's nodes keyed by node id, as serialized by deepeval's DAG metric. Judgement nodes list their
childrenby id; verdict nodes carry averdictand ascore, or point at another metric bymetric_name.
Response
Create Metric succeeded.
successbooleanIndicates if the request was successful.
dataobjectA custom metric: how it scores, and which test case fields it needs.
Show 9 propertiesHide 9 properties
idstringThis is the unique id of the metric.
namestringThis is the name of the metric, unique within your project.
algorithmenum | nullThe algorithm the metric is evaluated with. GEVAL scores against criteria or evaluation steps, DAG walks a decision graph, CODE runs your own code, and DEFAULT is a built-in metric.
Show 4 enum valuesHide 4 enum values
DEFAULTDAGGEVALCODE
criteriastring | nullThis is the criteria the metric scores against, or null when it uses evaluation steps.
evaluationStepsarray | nullThese are the steps the metric follows to score, or null when it uses criteria.
rubricarray | nullThese are the score ranges that anchor how the metric scores, or null.
Show 2 propertiesHide 2 properties
scoreRangelist of anyThe inclusive start and end of the score range this outcome describes, each between 0 and 10, with the start no greater than the end.
expectedOutcomestringWhat a response scoring in this range looks like.
dagobject | nullThe decision graph of a DAG metric. It is validated on write, and metric references are resolved against the metrics in your project.
Show 1 propertyHide 1 property
nodesobjectThe graph's nodes keyed by node id, as serialized by deepeval's DAG metric. Judgement nodes list their
childrenby id; verdict nodes carry averdictand ascore, or point at another metric bymetric_name.
multiTurnbooleanThis is true when the metric evaluates conversations rather than single test cases.
requiredParameterslist of enumsThe test case fields the metric needs to run.
Show 14 enum valuesHide 14 enum values
inputactualOutputexpectedOutputcontextexpectedToolscontentrolescenarioexpectedOutcometurnstoolsCalledretrievalContextmetadatatags
deprecatedbooleanIndicates if this endpoint is deprecated.