Skip to main content
POST
Optimize metric

Authorizations

Authorization
string
header
required

API key authorization. Pass your API key in the Authorization header as a Bearer token. Both new (gsk_*) and legacy (gsk-) API keys are accepted, e.g. Authorization: Bearer gsk_... or Authorization: Bearer gsk-....

Path Parameters

id
string
required

Source Metric ID

Response

Optimized metric placeholder created successfully

id
string
Example:

"metric_123"

metricGroupId
string
read-only

Identifier shared by every metric in the same revision family. Server-managed — derived from parentMetricId on create (or generated for roots). Cannot be set by the caller.

Example:

"metric_123"

parentMetricId
string | null

Id of the direct parent metric. On create, providing this value turns the new metric into a revision: it joins the parent's family and (if the parent is active) flips the parent to legacy. Omit or null to create a root metric in a fresh group. On responses, this is the recorded parent edge (null for roots).

Example:

"metric_122"

organizationId
string | null
Example:

"org_123"

userId
string | null
Example:

"user_123"

name
string
Example:

"Accuracy"

evaluationParams
string[]

Ordered list of inference-result fields the evaluator needs (e.g. input, actualOutput, expectedOutput, retrievalContext). Determines which data the evaluation engine extracts from each inference result.

Example:
source
enum<string> | null

Evaluation method for the metric. FULL_PROMPT is deprecated for creation — POST /metrics rejects it with a 400. Use PARTIAL_PROMPT for new AI Evaluation metrics. The value remains in the enum because existing FULL_PROMPT metrics are still returned by reads and filters.

Available options:
SELF_HOSTED,
FULL_PROMPT,
PARTIAL_PROMPT,
HUMAN_EVALUATION,
GEVAL,
DEEPEVAL,
DETERMINISTIC
Example:

"PARTIAL_PROMPT"

judgePrompt
string | null
Example:

"Evaluate the accuracy of the response"

tags
string[]
Example:
description
string | null
Example:

"Measures the accuracy of responses"

documentationUrl
string | null
Example:

"https://docs.example.com/metrics/accuracy"

evaluatorModelName
string | null
Example:

"GPT-4"

areEvalParamsTop
boolean | null

When true, evaluationParams are injected at the top level of the evaluator prompt instead of nested inside the conversation context.

isBeingOptimized
boolean
read-only

Whether the metric is currently being optimized.

specificationIds
string[]
Example:
userGroupIds
string[]
Example:
createdAt
string<date-time>
legacyAt
string<date-time> | null
disabledAt
string<date-time> | null