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

# Create a new assistant test

> Creates a comprehensive test configuration for evaluating AI assistant performance



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/ai/assistants.yml post /ai/assistants/tests
openapi: 3.1.0
info:
  title: Telnyx AI Assistants API
  version: 2.0.0
  description: >-
    API for managing AI Assistants, including CRUD fields, versions, tags,
    integrations, MCP servers, and shared tools.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /ai/assistants/tests:
    post:
      tags:
        - Assistants
      summary: Create a new assistant test
      description: >-
        Creates a comprehensive test configuration for evaluating AI assistant
        performance
      operationId: create_assistant_test_public_assistants_tests_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAssistantTestRequest'
      responses:
        '201':
          description: Returns the created test configuration with assigned test ID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AssistantTestResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      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 assistantTest = await client.ai.assistants.tests.create({
              destination: '+15551234567',
              instructions:
                'Act as a frustrated customer who received a damaged product. Ask for a refund and escalate if not satisfied with the initial response.',
              name: 'Customer Support Bot Test',
              rubric: [
                { criteria: 'Assistant responds within 30 seconds', name: 'Response Time' },
                { criteria: 'Provides correct product information', name: 'Accuracy' },
              ],
            });

            console.log(assistantTest.test_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
            )
            assistant_test = client.ai.assistants.tests.create(
                destination="+15551234567",
                instructions="Act as a frustrated customer who received a damaged product. Ask for a refund and escalate if not satisfied with the initial response.",
                name="Customer Support Bot Test",
                rubric=[{
                    "criteria": "Assistant responds within 30 seconds",
                    "name": "Response Time",
                }, {
                    "criteria": "Provides correct product information",
                    "name": "Accuracy",
                }],
            )
            print(assistant_test.test_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\tassistantTest, err := client.AI.Assistants.Tests.New(context.TODO(), telnyx.AIAssistantTestNewParams{\n\t\tDestination:  \"+15551234567\",\n\t\tInstructions: \"Act as a frustrated customer who received a damaged product. Ask for a refund and escalate if not satisfied with the initial response.\",\n\t\tName:         \"Customer Support Bot Test\",\n\t\tRubric: []telnyx.AIAssistantTestNewParamsRubric{{\n\t\t\tCriteria: \"Assistant responds within 30 seconds\",\n\t\t\tName:     \"Response Time\",\n\t\t}, {\n\t\t\tCriteria: \"Provides correct product information\",\n\t\t\tName:     \"Accuracy\",\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", assistantTest.TestID)\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.assistants.tests.AssistantTest;
            import com.telnyx.sdk.models.ai.assistants.tests.TestCreateParams;

            public final class Main {
                private Main() {}

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

                    TestCreateParams params = TestCreateParams.builder()
                        .destination("+15551234567")
                        .instructions("Act as a frustrated customer who received a damaged product. Ask for a refund and escalate if not satisfied with the initial response.")
                        .name("Customer Support Bot Test")
                        .addRubric(TestCreateParams.Rubric.builder()
                            .criteria("Assistant responds within 30 seconds")
                            .name("Response Time")
                            .build())
                        .addRubric(TestCreateParams.Rubric.builder()
                            .criteria("Provides correct product information")
                            .name("Accuracy")
                            .build())
                        .build();
                    AssistantTest assistantTest = client.ai().assistants().tests().create(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

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

            assistant_test = telnyx.ai.assistants.tests.create(
              destination: "+15551234567",
              instructions: "Act as a frustrated customer who received a damaged product. Ask for a refund and escalate if not satisfied with the initial response.",
              name: "Customer Support Bot Test",
              rubric: [
                {criteria: "Assistant responds within 30 seconds", name: "Response Time"},
                {criteria: "Provides correct product information", name: "Accuracy"}
              ]
            )

            puts(assistant_test)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\AI\Assistants\Tests\TelnyxConversationChannel;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $assistantTest = $client->ai->assistants->tests->create(
                destination: '+15551234567',
                instructions: 'Act as a frustrated customer who received a damaged product. Ask for a refund and escalate if not satisfied with the initial response.',
                name: 'Customer Support Bot Test',
                rubric: [
                  [
                    'criteria' => 'Assistant responds within 30 seconds',
                    'name' => 'Response Time',
                  ],
                  [
                    'criteria' => 'Provides correct product information',
                    'name' => 'Accuracy',
                  ],
                ],
                description: 'description',
                maxDurationSeconds: 1,
                telnyxConversationChannel: TelnyxConversationChannel::WEB_CHAT,
                testSuite: 'test_suite',
              );

              var_dump($assistantTest);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:assistants:tests create \
              --api-key 'My API Key' \
              --destination +15551234567 \
              --instructions 'Act as a frustrated customer who received a damaged product. Ask for a refund and escalate if not satisfied with the initial response.' \
              --name 'Customer Support Bot Test' \
              --rubric '{criteria: Assistant responds within 30 seconds, name: Response Time}' \
              --rubric '{criteria: Provides correct product information, name: Accuracy}'
components:
  schemas:
    CreateAssistantTestRequest:
      properties:
        name:
          type: string
          maxLength: 255
          minLength: 1
          title: Name
          description: >-
            A descriptive name for the assistant test. This will be used to
            identify the test in the UI and reports.
          example: Customer Support Bot Test
        description:
          type: string
          maxLength: 1000
          title: Description
          description: >-
            Optional detailed description of what this test evaluates and its
            purpose. Helps team members understand the test's objectives.
        telnyx_conversation_channel:
          allOf:
            - $ref: '#/components/schemas/TelnyxConversationChannel'
          description: >-
            The communication channel through which the test will be conducted.
            Determines how the assistant will receive and respond to test
            messages.
          default: web_chat
          example: web_chat
        destination:
          type: string
          minLength: 1
          title: Destination
          description: >-
            The target destination for the test conversation. Format depends on
            the channel: phone number for SMS/voice, webhook URL for web chat,
            etc.
          example: '+15551234567'
        max_duration_seconds:
          type: integer
          maximum: 3600
          minimum: 1
          title: Max Duration Seconds
          description: >-
            Maximum duration in seconds that the test conversation should run
            before timing out. If not specified, uses system default timeout.
        test_suite:
          type: string
          maxLength: 100
          title: Test Suite
          description: >-
            Optional test suite name to group related tests together. Useful for
            organizing tests by feature, team, or release cycle.
        instructions:
          type: string
          maxLength: 5000
          minLength: 1
          title: Instructions
          description: >-
            Detailed instructions that define the test scenario and what the
            assistant should accomplish. This guides the test execution and
            evaluation.
          example: >-
            Act as a frustrated customer who received a damaged product. Ask for
            a refund and escalate if not satisfied with the initial response.
        rubric:
          items:
            type: object
            required:
              - name
              - criteria
            properties:
              name:
                type: string
                description: >-
                  Label for the evaluation criterion, e.g., Empathy, Accuracy,
                  Clarity.
              criteria:
                type: string
                description: >-
                  Specific guidance on how to assess the assistant’s performance
                  for this rubric item.
            additionalProperties: false
          type: array
          minItems: 1
          title: Rubric
          description: >-
            Evaluation criteria used to assess the assistant's performance. Each
            rubric item contains a name and specific criteria for evaluation.
          example:
            - criteria: Assistant responds within 30 seconds
              name: Response Time
            - criteria: Provides correct product information
              name: Accuracy
      type: object
      required:
        - name
        - destination
        - instructions
        - rubric
      title: CreateAssistantTestRequest
      description: >-
        Request model for creating a new assistant test.


        This model defines all the required and optional parameters needed to
        create

        a comprehensive test for an AI assistant, including test configuration,

        evaluation criteria, and scheduling options.
    AssistantTestResponse:
      properties:
        test_id:
          type: string
          format: uuid
          title: Test Id
          description: Unique identifier for the assistant test.
          example: 123e4567-e89b-12d3-a456-426614174000
        name:
          type: string
          title: Name
          description: Human-readable name of the test.
          example: Customer Support Bot Test
        description:
          type: string
          title: Description
          description: Detailed description of the test's purpose and scope.
        telnyx_conversation_channel:
          allOf:
            - $ref: '#/components/schemas/TelnyxConversationChannel'
          description: Communication channel used for test execution.
          example: web_chat
        destination:
          type: string
          title: Destination
          description: Target destination for test conversations.
        max_duration_seconds:
          type: integer
          title: Max Duration Seconds
          description: Maximum allowed duration for test execution in seconds.
        test_suite:
          type: string
          title: Test Suite
          description: Test suite grouping for organizational purposes.
        instructions:
          type: string
          title: Instructions
          description: Detailed test scenario instructions and objectives.
        rubric:
          items:
            type: object
            required:
              - name
              - criteria
            properties:
              name:
                type: string
                description: >-
                  Label for the evaluation criterion, e.g., Empathy, Accuracy,
                  Clarity.
              criteria:
                type: string
                description: >-
                  Specific guidance on how to assess the assistant’s performance
                  for this rubric item.
            additionalProperties: false
          type: array
          title: Rubric
          description: Evaluation criteria used to assess test performance.
          example:
            - criteria: Responds within 30 seconds
              name: Response Time
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Timestamp when the test was created.
          example: '2024-01-16T09:00:00Z'
      type: object
      required:
        - test_id
        - name
        - telnyx_conversation_channel
        - rubric
        - created_at
      title: AssistantTestResponse
      description: |-
        Response model containing complete assistant test information.

        Returns all test configuration details including evaluation criteria,
        scheduling, and metadata. Used when retrieving individual tests or
        after creating/updating tests.
    HTTPValidationError:
      title: HTTPValidationError
      type: object
      properties:
        detail:
          title: Detail
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
    TelnyxConversationChannel:
      type: string
      enum:
        - phone_call
        - web_call
        - sms_chat
        - web_chat
      title: TelnyxConversationChannel
    ValidationError:
      title: ValidationError
      required:
        - loc
        - msg
        - type
      type: object
      properties:
        loc:
          title: Location
          type: array
          items:
            anyOf:
              - type: string
              - type: integer
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````