> ## 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.

# 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.



## OpenAPI

````yaml /openapi/source/external/inference/inference-ai-tests.json post /ai/tests/test_framework/v1/scenarios/generate-bg
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/generate-bg:
    post:
      tags:
        - AI Tests
      summary: Generate evaluator scenarios
      description: >-
        Starts background generation of evaluator scenarios for a test agent.
        Returns a progress ID to poll with the generate-scenarios-progress
        endpoint.
      operationId: generate_evaluator_scenarios
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateEvaluatorScenariosRequest'
            example:
              num_scenarios: 5
              agent_id: 1259
              extra_instructions: Focus on angry customers asking about refunds.
              scenario_type: workflow
              generate_expected_outcomes: true
      responses:
        '200':
          description: Scenario generation initiated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScenarioGenerationResponse'
              example:
                progress_id: b7e4c1a2-3d4f-5a6b-8c9d-0e1f2a3b4c5d
        '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.
components:
  schemas:
    GenerateEvaluatorScenariosRequest:
      type: object
      properties:
        num_scenarios:
          type: integer
          description: How many scenarios to generate.
        agent_id:
          type: integer
        extra_instructions:
          type: string
          description: Optional guidance steering scenario generation.
        tags:
          type: array
          items:
            type: string
        generate_expected_outcomes:
          type: boolean
          description: Whether to generate expected-outcome prompts for the scenarios.
        first_message:
          type: string
        personalities:
          type: array
          items:
            type: integer
        test_profile:
          type: integer
        scenario_type:
          type: string
          enum:
            - workflow
            - red_teaming_voice
            - red_teaming_text
          description: Type of scenario to generate.
        inbound_phone_number:
          type:
            - integer
            - 'null'
        tool_ids:
          type: array
          items:
            type: string
        folder_path:
          type:
            - string
            - 'null'
      required:
        - num_scenarios
      example:
        num_scenarios: 5
        agent_id: 1259
        extra_instructions: Focus on angry customers asking about refunds.
        scenario_type: workflow
        generate_expected_outcomes: true
    ScenarioGenerationResponse:
      type: object
      properties:
        progress_id:
          type: string
          description: Identifier to poll generation progress with.
      required:
        - progress_id
      example:
        progress_id: b7e4c1a2-3d4f-5a6b-8c9d-0e1f2a3b4c5d
    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

````