> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Improve evaluator scenarios

> Starts an interactive session that improves selected evaluator scenarios from a natural-language instruction. Returns a progress ID to poll with the improve-scenarios-progress endpoint.



## OpenAPI

````yaml /openapi/source/external/inference/inference-ai-tests.json post /ai/tests/test_framework/v1/scenarios/scenario-agent
openapi: 3.1.0
info:
  version: 2.0.0
  title: Telnyx API
  x-latency-category: responsive
  x-endpoint-cost: light
  description: SIP trunking, SMS, MMS, Call Control and Telephony Data Services.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
    description: Version 2.0.0 of the Telnyx API
security:
  - bearerAuth: []
tags:
  - name: AI Tests
    description: >-
      Test agents, evaluator scenarios, metrics, and run results for the AI test
      framework.
paths:
  /ai/tests/test_framework/v1/scenarios/scenario-agent:
    post:
      tags:
        - AI Tests
      summary: Improve evaluator scenarios
      description: >-
        Starts an interactive session that improves selected evaluator scenarios
        from a natural-language instruction. Returns a progress ID to poll with
        the improve-scenarios-progress endpoint.
      operationId: improve_evaluator_scenarios
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImproveScenariosRequest'
            example:
              user_message: Make the callers ask about damaged packaging too.
              scenarios: all
              agent_id: 1259
              apply_changes: true
      responses:
        '200':
          description: Improvement session initiated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImproveScenariosResponse'
              example:
                progress_id: c8f5d2b3-4e5f-6a7b-9c0d-1f2a3b4c5d6e
                session_id: 417
        '400':
          description: Bad Request. The AI Tests service rejected the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiTestsErrorResponse'
              example:
                errors:
                  - code: '10015'
                    title: Bad Request
                    detail: The AI Tests service rejected the request.
        '401':
          description: Unauthorized. Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiTestsErrorResponse'
              example:
                errors:
                  - code: '10003'
                    title: Unauthorized
                    detail: The API key is missing or invalid.
        '404':
          description: >-
            Not Found. The requested resource does not exist or is not enabled
            for your account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiTestsErrorResponse'
              example:
                errors:
                  - code: '10005'
                    title: Not Found
                    detail: The requested resource or URL could not be found.
        '422':
          description: Unprocessable Entity. A validation error occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiTestsErrorResponse'
              example:
                errors:
                  - code: '10018'
                    title: Unprocessable Entity
                    detail: Validation failed for the request payload.
        '429':
          description: Too Many Requests. The AI Tests service rate-limited the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiTestsErrorResponse'
              example:
                errors:
                  - code: '10029'
                    title: Too Many Requests
                    detail: Too many requests; retry later.
        '503':
          description: Service Unavailable. The AI Tests service is unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiTestsErrorResponse'
              example:
                errors:
                  - code: '10063'
                    title: Service Unavailable
                    detail: The test framework service is temporarily unavailable.
      x-codeSamples:
        - lang: JavaScript
          source: >-
            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.scenarioAgent({
              scenarios: 'scenarios',
              user_message: 'user_message',
            });


            console.log(response.progress_id);
        - lang: Python
          source: >
            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.scenario_agent(
                scenarios="scenarios",
                user_message="user_message",
            )

            print(response.progress_id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.AI.Tests.TestFramework.V1.Scenarios.ScenarioAgent(\n\t\tcontext.TODO(),\n\t\ttelnyx.AITestTestFrameworkV1ScenarioScenarioAgentParams{\n\t\t\tScenarios:   \"scenarios\",\n\t\t\tUserMessage: \"user_message\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
        - lang: Java
          source: >-
            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.ScenarioScenarioAgentParams;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    ScenarioScenarioAgentParams params = ScenarioScenarioAgentParams.builder()
                        .scenarios("scenarios")
                        .userMessage("user_message")
                        .build();
                    var response = client.ai().tests().testFramework().v1().scenarios().scenarioAgent(params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


            telnyx = Telnyx::Client.new(api_key: "My API Key")


            response =
            telnyx.ai.tests.test_framework.v1.scenarios.scenario_agent(scenarios:
            "scenarios", user_message: "user_message")


            puts(response)
        - lang: PHP
          source: >-
            <?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->scenarioAgent(
                scenarios: 'scenarios',
                user_message: 'user_message',
              );

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:tests:test-framework:v1:scenarios scenario-agent \
              --api-key 'My API Key' \
              --user-message user_message \
              --scenarios scenarios
components:
  schemas:
    ImproveScenariosRequest:
      type: object
      properties:
        user_message:
          type: string
          description: What the assistant should improve about the selected scenarios.
        scenarios:
          type:
            - array
            - string
          items: {}
          description: Scenario IDs to improve, or the literal string 'all'.
        agent_id:
          type:
            - integer
            - 'null'
        session_id:
          type:
            - integer
            - 'null'
        context:
          type:
            - array
            - 'null'
          items:
            type: object
            properties:
              role:
                type: string
              content:
                type: string
              timestamp:
                type: string
        apply_changes:
          type: boolean
        updated_scenarios:
          type: array
          items:
            type: object
            additionalProperties: true
        num_scenarios:
          type: integer
        knowledge_base:
          type: array
          items:
            type: integer
        agent_resolution_response:
          type: string
        scenarios_needing_agent:
          type: array
          items:
            type: integer
        pending_tool_calls:
          type:
            - array
            - 'null'
          items:
            type: object
            additionalProperties: true
      required:
        - user_message
        - scenarios
      example:
        user_message: Make the callers ask about damaged packaging too.
        scenarios: all
        agent_id: 1259
        apply_changes: true
    ImproveScenariosResponse:
      type: object
      properties:
        progress_id:
          type: string
        session_id:
          type:
            - integer
            - 'null'
      required:
        - progress_id
      example:
        progress_id: c8f5d2b3-4e5f-6a7b-9c0d-1f2a3b4c5d6e
        session_id: 417
    AiTestsErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                description: Telnyx error code.
              title:
                type: string
              detail:
                type: string
              source:
                type: object
                properties:
                  pointer:
                    type: string
            required:
              - code
              - title
      required:
        - errors
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````