Generate evaluator scenarios
Starts background generation of evaluator scenarios for a test agent. Returns a progress ID to poll with the generate-scenarios-progress endpoint.
POST
/
ai
/
tests
/
test_framework
/
v1
/
scenarios
/
generate-bg
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.ai.tests.testFramework.v1.scenarios.generateBg({
num_scenarios: 0,
});
console.log(response.progress_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
)
response = client.ai.tests.test_framework.v1.scenarios.generate_bg(
num_scenarios=0,
)
print(response.progress_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"),
)
response, err := client.AI.Tests.TestFramework.V1.Scenarios.GenerateBg(
context.TODO(),
telnyx.AITestTestFrameworkV1ScenarioGenerateBgParams{
NumScenarios: 1,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.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.scenarios.ScenarioGenerateBgParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
ScenarioGenerateBgParams params = ScenarioGenerateBgParams.builder()
.numScenarios(0)
.build();
var response = client.ai().tests().testFramework().v1().scenarios().generateBg(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.ai.tests.test_framework.v1.scenarios.generate_bg(num_scenarios: 0)
puts(response)<?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 {
$response = $client->ai->tests->testFramework->v1->scenarios->generateBg(
num_scenarios: 0,
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx ai:tests:test-framework:v1:scenarios generate-bg \
--api-key 'My API Key' \
--num-scenarios 0curl --request POST \
--url https://api.telnyx.com/v2/ai/tests/test_framework/v1/scenarios/generate-bg \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"num_scenarios": 5,
"agent_id": 1259,
"extra_instructions": "Focus on angry customers asking about refunds.",
"scenario_type": "workflow",
"generate_expected_outcomes": true
}
'{
"progress_id": "b7e4c1a2-3d4f-5a6b-8c9d-0e1f2a3b4c5d"
}{
"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
application/json
How many scenarios to generate.
Optional guidance steering scenario generation.
Whether to generate expected-outcome prompts for the scenarios.
Type of scenario to generate.
Available options:
workflow, red_teaming_voice, red_teaming_text Response
Scenario generation initiated.
Identifier to poll generation progress with.
Was this page helpful?
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.ai.tests.testFramework.v1.scenarios.generateBg({
num_scenarios: 0,
});
console.log(response.progress_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
)
response = client.ai.tests.test_framework.v1.scenarios.generate_bg(
num_scenarios=0,
)
print(response.progress_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"),
)
response, err := client.AI.Tests.TestFramework.V1.Scenarios.GenerateBg(
context.TODO(),
telnyx.AITestTestFrameworkV1ScenarioGenerateBgParams{
NumScenarios: 1,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.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.scenarios.ScenarioGenerateBgParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
ScenarioGenerateBgParams params = ScenarioGenerateBgParams.builder()
.numScenarios(0)
.build();
var response = client.ai().tests().testFramework().v1().scenarios().generateBg(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.ai.tests.test_framework.v1.scenarios.generate_bg(num_scenarios: 0)
puts(response)<?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 {
$response = $client->ai->tests->testFramework->v1->scenarios->generateBg(
num_scenarios: 0,
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx ai:tests:test-framework:v1:scenarios generate-bg \
--api-key 'My API Key' \
--num-scenarios 0curl --request POST \
--url https://api.telnyx.com/v2/ai/tests/test_framework/v1/scenarios/generate-bg \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"num_scenarios": 5,
"agent_id": 1259,
"extra_instructions": "Focus on angry customers asking about refunds.",
"scenario_type": "workflow",
"generate_expected_outcomes": true
}
'{
"progress_id": "b7e4c1a2-3d4f-5a6b-8c9d-0e1f2a3b4c5d"
}{
"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."
}
]
}