Bulk create test metrics
Creates several metrics in one request. Accepts an array of metric objects and returns the created metrics.
curl --request POST \
--url https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
[
{
"name": "Greets within 5 seconds",
"description": "Returns whether the assistant greeted the caller within five seconds.",
"type": "llm_judge",
"eval_type": "continuous_qualitative",
"prompt": "Score whether the greeting was timely and natural."
}
]
'import requests
url = "https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create"
payload = [
{
"name": "Greets within 5 seconds",
"description": "Returns whether the assistant greeted the caller within five seconds.",
"type": "llm_judge",
"eval_type": "continuous_qualitative",
"prompt": "Score whether the greeting was timely and natural."
}
]
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
name: 'Greets within 5 seconds',
description: 'Returns whether the assistant greeted the caller within five seconds.',
type: 'llm_judge',
eval_type: 'continuous_qualitative',
prompt: 'Score whether the greeting was timely and natural.'
}
])
};
fetch('https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'name' => 'Greets within 5 seconds',
'description' => 'Returns whether the assistant greeted the caller within five seconds.',
'type' => 'llm_judge',
'eval_type' => 'continuous_qualitative',
'prompt' => 'Score whether the greeting was timely and natural.'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create"
payload := strings.NewReader("[\n {\n \"name\": \"Greets within 5 seconds\",\n \"description\": \"Returns whether the assistant greeted the caller within five seconds.\",\n \"type\": \"llm_judge\",\n \"eval_type\": \"continuous_qualitative\",\n \"prompt\": \"Score whether the greeting was timely and natural.\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("[\n {\n \"name\": \"Greets within 5 seconds\",\n \"description\": \"Returns whether the assistant greeted the caller within five seconds.\",\n \"type\": \"llm_judge\",\n \"eval_type\": \"continuous_qualitative\",\n \"prompt\": \"Score whether the greeting was timely and natural.\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"name\": \"Greets within 5 seconds\",\n \"description\": \"Returns whether the assistant greeted the caller within five seconds.\",\n \"type\": \"llm_judge\",\n \"eval_type\": \"continuous_qualitative\",\n \"prompt\": \"Score whether the greeting was timely and natural.\"\n }\n]"
response = http.request(request)
puts response.read_body[
{
"id": 266881,
"slug": "ai_interrupting_user",
"project": 16003,
"agent": null,
"agents": [],
"agent_names": [],
"name": "AI interrupting user",
"description": "Tells if the AI (main agent) interrupted user (testing agent) during the interaction.",
"function_name": "get_main_agent_interruption",
"type": "custom_code",
"eval_type": "numeric",
"enum_values": [],
"audio_enabled": false,
"observability_enabled": true,
"simulation_enabled": true,
"sampling_enabled": false,
"sample_rate": null,
"prompt": "",
"display_order": 1,
"evaluation_trigger": "always",
"trigger_type": "llm_judge",
"evaluation_trigger_prompt": "",
"evaluation_trigger_custom_code": "",
"priority_assignment_prompt": "",
"configuration": {},
"overall_score": 0,
"total_score": 0,
"kb_file_ids": [],
"knowledge_base_files": [],
"metric_cost": 0,
"alert_type": "disabled",
"significant_change_alert_status": "disabled",
"significant_change_alert_direction": "",
"window_size": 50,
"std_multiplier": 2,
"ewma_alpha": 0.1,
"add_to_new_agents": true,
"alert_filters": {},
"uses_llm_judge": false,
"user_defined": false
}
]{
"errors": [
{
"code": "10015",
"title": "Bad Request",
"detail": "The AI Tests service rejected the request."
}
]
}{
"errors": [
{
"code": "10003",
"title": "Unauthorized",
"detail": "The API key is missing or invalid."
}
]
}{
"errors": [
{
"code": "10005",
"title": "Not Found",
"detail": "The requested resource or URL could not be found."
}
]
}{
"errors": [
{
"code": "10018",
"title": "Unprocessable Entity",
"detail": "Validation failed for the request payload."
}
]
}{
"errors": [
{
"code": "10029",
"title": "Too Many Requests",
"detail": "Too many requests; retry later."
}
]
}{
"errors": [
{
"code": "10063",
"title": "Service Unavailable",
"detail": "The test framework service is temporarily unavailable."
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
How the metric is evaluated: custom_code or llm_judge.
What the metric scores: numeric, continuous_qualitative, or binary_workflow_adherence.
Judge prompt used by llm_judge metrics.
[ { "name": "Greets within 5 seconds", "description": "Returns whether the assistant greeted the caller within five seconds.", "type": "llm_judge", "eval_type": "continuous_qualitative", "prompt": "Score whether the greeting was timely and natural." } ]
Response
Test metrics created.
How the metric is evaluated: custom_code or llm_judge.
What the metric scores: numeric, continuous_qualitative, or binary_workflow_adherence.
Stable identifier of a built-in metric.
Test agent IDs the metric is attached to.
Built-in evaluation function used by custom_code metrics.
Allowed values for qualitative enum metrics.
Judge prompt used by llm_judge metrics.
Sliding window size the alert status is computed over.
Standard-deviation multiplier for significant-change alerts.
Smoothing factor for the alert trend.
Whether the metric is attached to newly created test agents by default.
[ { "id": 266881, "slug": "ai_interrupting_user", "project": 16003, "agent": null, "agents": [], "agent_names": [], "name": "AI interrupting user", "description": "Tells if the AI (main agent) interrupted user (testing agent) during the interaction.", "function_name": "get_main_agent_interruption", "type": "custom_code", "eval_type": "numeric", "enum_values": [], "audio_enabled": false, "observability_enabled": true, "simulation_enabled": true, "sampling_enabled": false, "sample_rate": null, "prompt": "", "display_order": 1, "evaluation_trigger": "always", "trigger_type": "llm_judge", "evaluation_trigger_prompt": "", "evaluation_trigger_custom_code": "", "priority_assignment_prompt": "", "configuration": {}, "overall_score": 0, "total_score": 0, "kb_file_ids": [], "knowledge_base_files": [], "metric_cost": 0, "alert_type": "disabled", "significant_change_alert_status": "disabled", "significant_change_alert_direction": "", "window_size": 50, "std_multiplier": 2, "ewma_alpha": 0.1, "add_to_new_agents": true, "alert_filters": {}, "uses_llm_judge": false, "user_defined": false } ]
Was this page helpful?
curl --request POST \
--url https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
[
{
"name": "Greets within 5 seconds",
"description": "Returns whether the assistant greeted the caller within five seconds.",
"type": "llm_judge",
"eval_type": "continuous_qualitative",
"prompt": "Score whether the greeting was timely and natural."
}
]
'import requests
url = "https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create"
payload = [
{
"name": "Greets within 5 seconds",
"description": "Returns whether the assistant greeted the caller within five seconds.",
"type": "llm_judge",
"eval_type": "continuous_qualitative",
"prompt": "Score whether the greeting was timely and natural."
}
]
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
name: 'Greets within 5 seconds',
description: 'Returns whether the assistant greeted the caller within five seconds.',
type: 'llm_judge',
eval_type: 'continuous_qualitative',
prompt: 'Score whether the greeting was timely and natural.'
}
])
};
fetch('https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'name' => 'Greets within 5 seconds',
'description' => 'Returns whether the assistant greeted the caller within five seconds.',
'type' => 'llm_judge',
'eval_type' => 'continuous_qualitative',
'prompt' => 'Score whether the greeting was timely and natural.'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create"
payload := strings.NewReader("[\n {\n \"name\": \"Greets within 5 seconds\",\n \"description\": \"Returns whether the assistant greeted the caller within five seconds.\",\n \"type\": \"llm_judge\",\n \"eval_type\": \"continuous_qualitative\",\n \"prompt\": \"Score whether the greeting was timely and natural.\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("[\n {\n \"name\": \"Greets within 5 seconds\",\n \"description\": \"Returns whether the assistant greeted the caller within five seconds.\",\n \"type\": \"llm_judge\",\n \"eval_type\": \"continuous_qualitative\",\n \"prompt\": \"Score whether the greeting was timely and natural.\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics/bulk_create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"name\": \"Greets within 5 seconds\",\n \"description\": \"Returns whether the assistant greeted the caller within five seconds.\",\n \"type\": \"llm_judge\",\n \"eval_type\": \"continuous_qualitative\",\n \"prompt\": \"Score whether the greeting was timely and natural.\"\n }\n]"
response = http.request(request)
puts response.read_body[
{
"id": 266881,
"slug": "ai_interrupting_user",
"project": 16003,
"agent": null,
"agents": [],
"agent_names": [],
"name": "AI interrupting user",
"description": "Tells if the AI (main agent) interrupted user (testing agent) during the interaction.",
"function_name": "get_main_agent_interruption",
"type": "custom_code",
"eval_type": "numeric",
"enum_values": [],
"audio_enabled": false,
"observability_enabled": true,
"simulation_enabled": true,
"sampling_enabled": false,
"sample_rate": null,
"prompt": "",
"display_order": 1,
"evaluation_trigger": "always",
"trigger_type": "llm_judge",
"evaluation_trigger_prompt": "",
"evaluation_trigger_custom_code": "",
"priority_assignment_prompt": "",
"configuration": {},
"overall_score": 0,
"total_score": 0,
"kb_file_ids": [],
"knowledge_base_files": [],
"metric_cost": 0,
"alert_type": "disabled",
"significant_change_alert_status": "disabled",
"significant_change_alert_direction": "",
"window_size": 50,
"std_multiplier": 2,
"ewma_alpha": 0.1,
"add_to_new_agents": true,
"alert_filters": {},
"uses_llm_judge": false,
"user_defined": false
}
]{
"errors": [
{
"code": "10015",
"title": "Bad Request",
"detail": "The AI Tests service rejected the request."
}
]
}{
"errors": [
{
"code": "10003",
"title": "Unauthorized",
"detail": "The API key is missing or invalid."
}
]
}{
"errors": [
{
"code": "10005",
"title": "Not Found",
"detail": "The requested resource or URL could not be found."
}
]
}{
"errors": [
{
"code": "10018",
"title": "Unprocessable Entity",
"detail": "Validation failed for the request payload."
}
]
}{
"errors": [
{
"code": "10029",
"title": "Too Many Requests",
"detail": "Too many requests; retry later."
}
]
}{
"errors": [
{
"code": "10063",
"title": "Service Unavailable",
"detail": "The test framework service is temporarily unavailable."
}
]
}