Launch Week 3: Five days of launches

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.

POST/v2/metrics-batch
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
          }
        }
      }
    }
  ]
}'
200
{
  "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
            }
          }
        },
        "multiTurn": false,
        "requiredParameters": [
          "actualOutput",
          "expectedOutput"
        ]
      }
    ]
  },
  "deprecated": false
}

Headers

  • CONFIDENT_API_KEYstringRequired

    The API key of your Confident AI project.

Request body

  • metricslist of objectsRequired

    The metrics to create. Names must be unique within the batch for the same multiTurn, and DAG metrics are not accepted here.

    Show 8 propertiesHide 8 properties
    • namestringRequired

      The name of the metric, unique within your project.

    • multiTurnboolean

      This is true when the metric evaluates conversations rather than single test cases. It decides which evaluationParams are valid and cannot be changed later.

    • criteriastring

      The criteria the metric scores against. A GEVAL metric needs criteria or evaluationSteps.

    • evaluationStepslist of strings

      The steps the metric follows to score, as an alternative to criteria.

    • evaluationParamslist of enums

      The 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
      • input
      • actualOutput
      • expectedOutput
      • context
      • expectedTools
      • content
      • role
      • scenario
      • expectedOutcome
      • turns
      • toolsCalled
      • retrievalContext
      • metadata
      • tags
    • rubriclist of objects

      Score ranges that anchor how the metric scores.

      Show 2 propertiesHide 2 properties
      • scoreRangelist of anyRequired

        The inclusive start and end of the score range this outcome describes, each between 0 and 10, with the start no greater than the end.

      • expectedOutcomestringRequired

        What a response scoring in this range looks like.

    • algorithmenum

      The 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
      • DEFAULT
      • DAG
      • GEVAL
      • CODE
    • dagobject

      The 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
      • nodesobjectRequired

        The graph's nodes keyed by node id, as serialized by deepeval's DAG metric. Judgement nodes list their children by id; verdict nodes carry a verdict and a score, or point at another metric by metric_name.

Response

Batch Create Metrics succeeded.

  • successboolean

    Indicates if the request was successful.

  • dataobject

    Show 1 propertyHide 1 property
    • metricslist of objects

      This is the list of metrics.

      Show 9 propertiesHide 9 properties
      • idstring

        This is the unique id of the metric.

      • namestring

        This is the name of the metric, unique within your project.

      • algorithmenum | null

        The 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
        • DEFAULT
        • DAG
        • GEVAL
        • CODE
      • criteriastring | null

        This is the criteria the metric scores against, or null when it uses evaluation steps.

      • evaluationStepsarray | null

        These are the steps the metric follows to score, or null when it uses criteria.

      • rubricarray | null

        These are the score ranges that anchor how the metric scores, or null.

        Show 2 propertiesHide 2 properties
        • scoreRangelist of any

          The inclusive start and end of the score range this outcome describes, each between 0 and 10, with the start no greater than the end.

        • expectedOutcomestring

          What a response scoring in this range looks like.

      • dagobject | null

        The 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
        • nodesobject

          The graph's nodes keyed by node id, as serialized by deepeval's DAG metric. Judgement nodes list their children by id; verdict nodes carry a verdict and a score, or point at another metric by metric_name.

      • multiTurnboolean

        This is true when the metric evaluates conversations rather than single test cases.

      • requiredParameterslist of enums

        The test case fields the metric needs to run.

        Show 14 enum valuesHide 14 enum values
        • input
        • actualOutput
        • expectedOutput
        • context
        • expectedTools
        • content
        • role
        • scenario
        • expectedOutcome
        • turns
        • toolsCalled
        • retrievalContext
        • metadata
        • tags
  • deprecatedboolean

    Indicates if this endpoint is deprecated.

Built byConfident AI