Skip to main content
POST
/
api
/
v1
/
metrics
Create a metric
curl --request POST \
  --url https://app.dimred.com/api/v1/metrics \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "project_id": "proj_abc123",
  "code": "def metric_func(output, expected):\n    return 1.0 if output == expected else 0.0",
  "metric_name": "Exact Match",
  "metric_description": "Checks if output exactly matches expected"
}'
{
  "metric_id": "<string>",
  "metric_name": "<string>",
  "metric_description": "<string>",
  "metric_definition": "<string>",
  "storage_type": "inline",
  "status": "<string>",
  "message": "<string>",
  "validation": {
    "valid": true,
    "has_metric_func": true,
    "has_imports": true,
    "function_signature": "<string>",
    "error": "<string>"
  },
  "metadata_auto_generated": true,
  "creation_method": "auto_selection"
}

Authorizations

x-api-key
string
header
required

API key for authentication. Obtain from your DimRed dashboard. The organization context is automatically derived from the API key.

Body

application/json
project_id
string
required

Project identifier

code
string
required

Python code defining metric_func(output, expected) -> float

metric_name
string | null

Name of the metric (auto-generated if not provided)

metric_description
string | null

Description of the metric

metric_config
object | null

Additional configuration

dataset_schema
object | null

Dataset schema for context

metric_metadata
object | null

Metadata for auto-generation (e.g., creation_method, schema_key)

Response

Metric created successfully

metric_id
string

Unique identifier for the metric

metric_name
string

Name of the metric

metric_description
string | null

Description of the metric

metric_definition
string | null

The code definition

storage_type
string
default:inline

How the metric is stored

status
string

Status of the metric creation

message
string

Status message

validation
object | null

Validation results

metadata_auto_generated
boolean

Whether metadata was auto-generated

creation_method
enum<string>

How the metric was created

Available options:
auto_selection,
custom_code,
llm_judge