Batch Create Metrics
(v2)POST
Creates several GEVAL metrics at once and returns the ones created. Metrics whose name already exists in the project are skipped. DAG metrics must be created one at a time.
curl -X POST "https://api.confident-ai.com/v2/metrics-batch" \
-H "CONFIDENT_API_KEY: <PROJECT-API-KEY>" \
-H "Content-Type: application/json" \
-d '{
"metrics": [
{
"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
}
}
},
"questions": [
{
"type": "noul",
"question": "Does the actual output answer the input?",
"weight": 2
}
],
"promptConfig": {
"messages": [
{
"role": "system",
"content": "You grade support answers."
},
{
"role": "user",
"content": "QUESTION: {{question}}\nANSWER: {{answer}}"
}
],
"variables": {
"question": {
"field": "input",
"path": [
"messages",
0,
"content"
]
},
"answer": {
"field": "output",
"path": [
"messages",
-1,
"content"
]
}
}
}
}
]
}'{
"success": true,
"data": {
"metrics": [
{
"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
}
}
},
"questions": [
{
"type": "noul",
"question": "Does the actual output answer the input?",
"weight": 2
}
],
"promptConfig": {
"messages": [
{
"role": "system",
"content": "You grade support answers."
},
{
"role": "user",
"content": "QUESTION: {{question}}\nANSWER: {{answer}}"
}
],
"variables": {
"question": {
"field": "input",
"path": [
"messages",
0,
"content"
]
},
"answer": {
"field": "output",
"path": [
"messages",
-1,
"content"
]
}
}
},
"multiTurn": false,
"requiredParameters": [
"actualOutput",
"expectedOutput"
]
}
]
},
"deprecated": false
}Headers
CONFIDENT_API_KEYstringRequiredThe API key of your Confident AI project.
Request body
metricslist of objectsRequiredThe metrics to create. Names must be unique within the batch for the same
multiTurn, andDAGmetrics are not accepted here.Show 10 propertiesHide 10 properties
namestringRequiredThe name of the metric, unique within your project.
multiTurnbooleanThis is
truewhen the metric evaluates conversations rather than single test cases. It decides whichevaluationParamsare valid and cannot be changed later.criteriastringThe criteria the metric scores against. A
GEVALmetric needscriteriaorevaluationSteps.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.
GEVALscores against criteria or evaluation steps,DAGwalks a decision graph,JEVALasks a decision model bounded questions,PROMPTsends your own judge prompt to the evaluation model,CODEruns your own code, andDEFAULTis a built-in metric.Show 6 enum valuesHide 6 enum values
DEFAULTDAGGEVALJEVALCODEPROMPT
dagobjectThe decision graph of a
DAGmetric. 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
DAGmetric. Judgement nodes list theirchildrenby id; verdict nodes carry averdictand ascore, or point at another metric bymetric_name.
questionslist of object | object | objectThe questions a
JEVALmetric asks the decision model. Required whenalgorithmisJEVAL.Show 3 variantsHide 3 variants
object
Show 5 propertiesHide 5 properties
typeenumRequiredShow 1 enum valueHide 1 enum value
noul
questionstringRequiredweightnumbertrueDescriptionstringfalseDescriptionstring
- OR
object
Show 4 propertiesHide 4 properties
typeenumRequiredShow 1 enum valueHide 1 enum value
score
questionstringRequiredweightnumberlevelslist of stringsRequiredBetween 2 and 10 ordered levels, worst first.
- OR
object
Show 4 propertiesHide 4 properties
typeenumRequiredShow 1 enum valueHide 1 enum value
choice
questionstringRequiredweightnumberoptionsobjectRequiredEach option maps to a credit between 0 and 1, or
nullto mark the question not applicable when that option is likely.
promptConfigobjectThe judge prompt of a
PROMPTmetric, and how its variables are filled. The judge scores from 0 to 10 and the score is normalized to 0 to 1.Show 2 propertiesHide 2 properties
messageslist of objectsRequiredThe judge prompt, as one or more messages.
Show 2 propertiesHide 2 properties
roleenumRequiredWho the message is from. A system message is only allowed first.
Show 3 enum valuesHide 3 enum values
systemuserassistant
contentstringRequiredThe message text. Use
{{name}}to insert a mapped variable.
variablesobjectRequiredMaps every
{{name}}used in the messages to the data it is filled with.
Response
Batch Create Metrics succeeded.
successbooleanIndicates if the request was successful.
dataobjectShow 1 propertyHide 1 property
metricslist of objectsThis is the list of metrics.
Show 11 propertiesHide 11 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.
GEVALscores against criteria or evaluation steps,DAGwalks a decision graph,JEVALasks a decision model bounded questions,PROMPTsends your own judge prompt to the evaluation model,CODEruns your own code, andDEFAULTis a built-in metric.Show 6 enum valuesHide 6 enum values
DEFAULTDAGGEVALJEVALCODEPROMPT
criteriastring | nullThis is the criteria the metric scores against, or
nullwhen it uses evaluation steps.evaluationStepsarray | nullThese are the steps the metric follows to score, or
nullwhen 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
DAGmetric. 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
DAGmetric. Judgement nodes list theirchildrenby id; verdict nodes carry averdictand ascore, or point at another metric bymetric_name.
questionslist of object | object | object | nullShow 3 variantsHide 3 variants
object
Show 5 propertiesHide 5 properties
typeenumShow 1 enum valueHide 1 enum value
noul
questionstringweightnumbertrueDescriptionstringfalseDescriptionstring
- OR
object
Show 4 propertiesHide 4 properties
typeenumShow 1 enum valueHide 1 enum value
score
questionstringweightnumberlevelslist of stringsBetween 2 and 10 ordered levels, worst first.
- OR
object
Show 4 propertiesHide 4 properties
typeenumShow 1 enum valueHide 1 enum value
choice
questionstringweightnumberoptionsobjectEach option maps to a credit between 0 and 1, or
nullto mark the question not applicable when that option is likely.
promptConfigobject | nullThe judge prompt of a
PROMPTmetric, and how its variables are filled. The judge scores from 0 to 10 and the score is normalized to 0 to 1.Show 2 propertiesHide 2 properties
messageslist of objectsThe judge prompt, as one or more messages.
Show 2 propertiesHide 2 properties
roleenumWho the message is from. A system message is only allowed first.
Show 3 enum valuesHide 3 enum values
systemuserassistant
contentstringThe message text. Use
{{name}}to insert a mapped variable.
variablesobjectMaps every
{{name}}used in the messages to the data it is filled with.
multiTurnbooleanThis is
truewhen 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.