Create a test metric
Creates a metric in your organization.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const AiTestMetric = await client.ai.tests.testFramework.v1.metrics.create({
name: 'name',
});
console.log(AiTestMetric.id);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
ai_test_metric = client.ai.tests.test_framework.v1.metrics.create(
name="name",
)
print(ai_test_metric.id)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
metric, err := client.AI.Tests.TestFramework.V1.Metrics.New(
context.TODO(),
telnyx.AITestTestFrameworkV1MetricNewParams{
Name: "name",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", metric.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.ai.tests.testFramework.v1.metrics.MetricCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
MetricCreateParams params = MetricCreateParams.builder()
.name("name")
.build();
var response = client.ai().tests().testFramework().v1().metrics().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
ai_test_metric = telnyx.ai.tests.test_framework.v1.metrics.create(name: "name")
puts(ai_test_metric)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$ai_test_metric = $client->ai->tests->testFramework->v1->metrics->create(
name: 'name',
);
var_dump($ai_test_metric);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx ai:tests:test-framework:v1:metrics create \
--api-key 'My API Key' \
--name namecurl --request POST \
--url https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"name": "Escalates on refund denial",
"description": "Returns a score for whether the assistant escalates when the caller's refund is denied.",
"type": "llm_judge",
"eval_type": "continuous_qualitative",
"prompt": "Score the assistant's escalation behaviour between 0.0 and 1.0.",
"agents": [
1259
],
"add_to_new_agents": false,
"simulation_enabled": true,
"observability_enabled": true
}
EOF{
"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.
Response
Test metric 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.
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const AiTestMetric = await client.ai.tests.testFramework.v1.metrics.create({
name: 'name',
});
console.log(AiTestMetric.id);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
ai_test_metric = client.ai.tests.test_framework.v1.metrics.create(
name="name",
)
print(ai_test_metric.id)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
metric, err := client.AI.Tests.TestFramework.V1.Metrics.New(
context.TODO(),
telnyx.AITestTestFrameworkV1MetricNewParams{
Name: "name",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", metric.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.ai.tests.testFramework.v1.metrics.MetricCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
MetricCreateParams params = MetricCreateParams.builder()
.name("name")
.build();
var response = client.ai().tests().testFramework().v1().metrics().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
ai_test_metric = telnyx.ai.tests.test_framework.v1.metrics.create(name: "name")
puts(ai_test_metric)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$ai_test_metric = $client->ai->tests->testFramework->v1->metrics->create(
name: 'name',
);
var_dump($ai_test_metric);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx ai:tests:test-framework:v1:metrics create \
--api-key 'My API Key' \
--name namecurl --request POST \
--url https://api.telnyx.com/v2/ai/tests/test_framework/v1/metrics \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"name": "Escalates on refund denial",
"description": "Returns a score for whether the assistant escalates when the caller's refund is denied.",
"type": "llm_judge",
"eval_type": "continuous_qualitative",
"prompt": "Score the assistant's escalation behaviour between 0.0 and 1.0.",
"agents": [
1259
],
"add_to_new_agents": false,
"simulation_enabled": true,
"observability_enabled": true
}
EOF{
"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."
}
]
}