Create metric
Create a new custom evaluation metric.
Required fields vary by metric type:
| Metric Type | Required Fields |
|---|---|
| METRIC_LLM_BINARY | prompt |
| METRIC_CATEGORICAL | prompt, categories |
| METRIC_NUMERICAL_LLM_JUDGE | prompt, min_value, max_value |
| METRIC_AUDIO_LLM_BINARY | prompt |
| METRIC_AUDIO_LLM_CATEGORICAL | prompt, categories |
| METRIC_AUDIO_LLM_NUMERICAL | prompt, min_value, max_value |
| METRIC_TOOLCALL | prompt |
| METRIC_METADATA_FIELD | metadata_field_type, metadata_field_key |
| METRIC_TRANSCRIPT_REGEX | regex_pattern |
| METRIC_PAUSE_ANALYSIS | min_pause_duration_seconds |
Authorizations
API key for authentication
Body
Create metric request
Display name
1 - 200Metric description
1 - 1000Metric evaluation type.
METRIC_LLM_BINARY- Yes/no LLM evaluationMETRIC_CATEGORICAL- Multi-class classificationMETRIC_NUMERICAL_LLM_JUDGE- Numerical scoring (1-N)METRIC_AUDIO_LLM_BINARY- Audio-based yes/noMETRIC_AUDIO_LLM_CATEGORICAL- Audio-based classificationMETRIC_AUDIO_LLM_NUMERICAL- Audio-based scoringMETRIC_TOOLCALL- Tool/function call evaluationMETRIC_METADATA_FIELD- Extract metadata fieldMETRIC_TRANSCRIPT_REGEX- Regex pattern matchingMETRIC_PAUSE_ANALYSIS- Speech pause detectionMETRIC_SQL_FLOAT- Custom SQL query over the simulation's data (setsql_query)METRIC_COMPOSITE_EVALUATION- Judges a list of criteria independently and reports how many were met (setcriteria_source, andcriteria_pathorcriteriato match)
METRIC_LLM_BINARY, METRIC_CATEGORICAL, METRIC_NUMERICAL_LLM_JUDGE, METRIC_AUDIO_LLM_BINARY, METRIC_AUDIO_LLM_CATEGORICAL, METRIC_AUDIO_LLM_NUMERICAL, METRIC_TOOLCALL, METRIC_METADATA_FIELD, METRIC_TRANSCRIPT_REGEX, METRIC_PAUSE_ANALYSIS, METRIC_SQL_FLOAT, METRIC_COMPOSITE_EVALUATION, METRIC_CUSTOM_AGENT_FAILS_TO_RESPOND, METRIC_CUSTOM_AGENT_NEEDS_REPROMPTING, METRIC_CUSTOM_AUDIO_FREQUENCY, METRIC_CUSTOM_AUDIO_SENTIMENT, METRIC_CUSTOM_END_REASON, METRIC_MATCH_EXPECTED_OUTPUT, METRIC_SPEAKING_TIME_PERCENTAGE, METRIC_SPECTROGRAM_PITCH_ANALYSIS, METRIC_VOLUME_PITCH_MISALIGNMENT, METRIC_WORDS_PER_MESSAGE_WITH_THRESHOLD LLM evaluation prompt. Required for LLM-based metrics.
Categories for classification. Required for categorical metrics.
2 - 50 elementsMinimum score. Required for numerical metrics.
Maximum score. Required for numerical metrics.
Field type. Required for METRIC_METADATA_FIELD.
STRING, NUMBER, BOOLEAN Metadata key. Required for METRIC_METADATA_FIELD.
Regex pattern. Required for METRIC_TRANSCRIPT_REGEX.
Speaker role filter. Aliases user and assistant are normalized on write.
agent, persona, user, assistant Min pause duration in seconds. Required for METRIC_PAUSE_ANALYSIS.
x >= 0.5x > 0x > 0x > 0above, below 1Neutral, Happy, Angry, Sad 0 <= x <= 1001UNKNOWN, IDLE_TIMEOUT, PERSONA_DISCONNECTED, AGENT_DISCONNECTED, PIPELINE_ERROR, REPETITION_LOOP, AUDIO_UPLOAD_PLAYBACK_COMPLETED, SCRIPT_COMPLETED, SCRIPT_DIVERGED 11Optional dot path; brackets must contain an integer index or comma-separated key=value filters.
1x > 0x >= 0<, <=, >, >=, ==, != SQL query run against the simulation's data. Required for METRIC_SQL_FLOAT.
The query returns one row per timestamp with a numeric value and a
start_offset_milliseconds; set aggregation_method (SUM, AVERAGE, MIN, MAX,
or COUNT; default AVERAGE) to reduce those rows to a single value, and unit
for the reported unit.
50000"SELECT start_offset_milliseconds, latency_milliseconds AS value FROM events"
Where the metric reads its criteria from. Required for METRIC_COMPOSITE_EVALUATION.
test_case reads a field off each test case (most commonly its expected behaviors),
test_case_attribute reads from the test case's attributes, and metric_metadata
uses the fixed list in criteria.
test_case, test_case_attribute, metric_metadata "test_case"
Path to the criteria on the source. Required when criteria_source is test_case
or test_case_attribute.
200"expected_behaviors"
Literal list of criteria. Required when criteria_source is metric_metadata.
How per-criterion verdicts aggregate into the metric's value. Each criterion is judged
independently as met or not met; percentage_of_criteria_met scores the fraction met
among the criteria the judge could evaluate.
percentage_of_criteria_met, count_of_criteria_met, all_criteria_met "percentage_of_criteria_met"
Custom prompt template used to evaluate each criterion. Include a {criterion}
placeholder; if it is omitted the criterion is appended to the prompt.
50000Inject OTel trace context into the LLM judge prompt during evaluation.
Supported for LLM judge metric types and METRIC_COMPOSITE_EVALUATION (METRIC_LLM_BINARY,
METRIC_CATEGORICAL, METRIC_NUMERICAL_LLM_JUDGE, METRIC_AUDIO_LLM_BINARY,
METRIC_AUDIO_LLM_CATEGORICAL, METRIC_AUDIO_LLM_NUMERICAL, METRIC_COMPOSITE_EVALUATION).
Override the LLM model used for metric evaluation. If omitted, the platform default
model is used. Use GET /v1/models/metric to list available models.
Not supported for audio metric types (METRIC_AUDIO_LLM_BINARY,
METRIC_AUDIO_LLM_CATEGORICAL, METRIC_AUDIO_LLM_NUMERICAL),
which always use the platform-default audio model.
Target condition for metric evaluation
- Option 1
- Option 2
Tags to associate with this metric. Null or omitted creates the metric with no tags. Pass [] for an empty tag list.
Response
Metric created
Metric resource