Skip to main content
POST
/
v1
/
metrics
curl --request POST \
  --url https://api.coval.dev/v1/metrics \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data @- <<EOF
{
  "metric_name": "Issue Resolved",
  "description": "Did the agent resolve the customer issue?",
  "metric_type": "METRIC_LLM_BINARY",
  "prompt": "Did the agent successfully resolve the customer's issue?"
}
EOF
{
  "metric": {
    "name": "metrics/abc123def456ghi789jklm",
    "id": "abc123def456ghi789jklm",
    "metric_name": "Customer Satisfaction",
    "description": "Evaluates customer satisfaction",
    "prompt": "Did the agent resolve the issue?",
    "categories": [
      "positive",
      "neutral",
      "negative"
    ],
    "min_value": 1,
    "max_value": 10,
    "metadata_field_key": "satisfaction_score",
    "regex_pattern": "(hello|hi)",
    "role": "agent",
    "min_pause_duration_seconds": 0.5,
    "include_traces": true,
    "runtime_config": {
      "model_version": "openai:gpt-4.1-mini-2025-04-14",
      "thinking_enabled": true
    },
    "target_condition": {
      "target_float": 123,
      "target_values": [
        "value1",
        "value2"
      ]
    },
    "tags": [
      "production",
      "llm"
    ],
    "created_by": "<string>",
    "create_time": "2023-11-07T05:31:56Z",
    "update_time": "2023-11-07T05:31:56Z"
  }
}

Authorizations

X-API-Key
string
header
required

API key for authentication

Body

application/json

Create metric request

metric_name
string
required

Display name

Required string length: 1 - 200
description
string
required

Metric description

Required string length: 1 - 1000
metric_type
enum<string>
required

Metric evaluation type.

  • METRIC_LLM_BINARY - Yes/no LLM evaluation
  • METRIC_CATEGORICAL - Multi-class classification
  • METRIC_NUMERICAL_LLM_JUDGE - Numerical scoring (1-N)
  • METRIC_AUDIO_LLM_BINARY - Audio-based yes/no
  • METRIC_AUDIO_LLM_CATEGORICAL - Audio-based classification
  • METRIC_AUDIO_LLM_NUMERICAL - Audio-based scoring
  • METRIC_TOOLCALL - Tool/function call evaluation
  • METRIC_METADATA_FIELD - Extract metadata field
  • METRIC_TRANSCRIPT_REGEX - Regex pattern matching
  • METRIC_PAUSE_ANALYSIS - Speech pause detection
Available options:
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
prompt
string

LLM evaluation prompt. Required for LLM-based metrics.

categories
string[]

Categories for classification. Required for categorical metrics.

Required array length: 2 - 50 elements
min_value
number

Minimum score. Required for numerical metrics.

max_value
number

Maximum score. Required for numerical metrics.

metadata_field_type
enum<string>

Field type. Required for METRIC_METADATA_FIELD.

Available options:
STRING,
NUMBER,
BOOLEAN
metadata_field_key
string

Metadata key. Required for METRIC_METADATA_FIELD.

regex_pattern
string

Regex pattern. Required for METRIC_TRANSCRIPT_REGEX.

role
enum<string>

Speaker role filter. Optional for METRIC_TRANSCRIPT_REGEX.

Available options:
agent,
user
min_pause_duration_seconds
number

Min pause duration in seconds. Required for METRIC_PAUSE_ANALYSIS.

Required range: x >= 0.5
include_traces
boolean

Inject OTel trace context into the LLM judge prompt during evaluation. Supported for LLM judge metric types only (METRIC_LLM_BINARY, METRIC_CATEGORICAL, METRIC_NUMERICAL_LLM_JUDGE, METRIC_AUDIO_LLM_BINARY, METRIC_AUDIO_LLM_CATEGORICAL, METRIC_AUDIO_LLM_NUMERICAL).

runtime_config
object

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
object

Target condition for metric evaluation

tags
string[] | null

Tags to associate with this metric. Null or omitted creates the metric with no tags. Pass [] for an empty tag list.

Example:
["production"]

Response

Metric created

metric
object
required

Metric resource