Create a metric
Creates an evaluation metric in a project. The config shape depends on type: an LLM-as-a-judge prompt, a predefined evaluator plus its settings, or custom scoring code. Creating a metric also records its first version.
Authorization
personalAccessToken Personal Access Token of a Dynamiq user — the only credential accepted by the management API (api.*). Prefix dyn_pat_ (legacy uak_ tokens still authenticate). Send as Authorization: Bearer <token>.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Body for POST /v1/metrics.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/v1/metrics" \ -H "Content-Type: application/json" \ -d '{ "name": "Answer relevance", "project_id": "6f0b2f1e-9d3a-4c2b-8e7f-1a2b3c4d5e6f", "type": "llm_as_a_judge", "config": { "llm": { "type": "dynamiq.connections.OpenAI", "model": "gpt-4o", "connection_id": "2b3c4d5e-6f70-4812-9a3b-4c5d6e7f8091" }, "instructions": "Score from 0 to 1 how well the answer addresses the question." } }'{
"data": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
"type": "llm_as_a_judge",
"config": {},
"latest_version_id": "8562ca50-d99e-4ec5-9529-9c17b0fd462e",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"created_by": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"first_name": "string",
"last_name": "string",
"avatar_url": "string"
},
"updated_by": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"first_name": "string",
"last_name": "string",
"avatar_url": "string"
}
}
}{
"error": {
"code": "bad_request",
"message": "Bad Request",
"details": {
"input": "cannot be blank"
}
}
}{
"error": {
"code": "unauthorized",
"message": "Unauthorized"
}
}{
"error": {
"code": "forbidden",
"message": "Forbidden"
}
}{
"error": {
"code": "not_found",
"message": "Not Found"
}
}List metrics
Lists the metrics of a project, ordered by `name` by default. The `project_id` query parameter is required.
Test metrics
Runs one or more metric configurations against sample input without persisting anything, returning each metric's score. Useful for tuning a metric's prompt or settings before saving it. Each entry carries a `metric` configuration (with its `type`) and the `input` record to score; an optional `input_transformer` remaps the fields the metric receives.