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

# Update a test metric

> Updates the specified metric.



## OpenAPI

````yaml /openapi/source/external/inference/inference-ai-tests.json patch /ai/tests/test_framework/v1/metrics/{id}
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/metrics/{id}:
    patch:
      tags:
        - AI Tests
      summary: Update a test metric
      description: Updates the specified metric.
      operationId: update_test_metric
      parameters:
        - name: id
          in: path
          required: true
          description: Numeric ID of the metric.
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAiTestMetricRequest'
            example:
              name: Escalates on refund denial
              prompt: >-
                Score the assistant's escalation behaviour between 0.0 and 1.0,
                considering tone.
              audio_enabled: true
      responses:
        '200':
          description: Updated test metric.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiTestMetric'
              example:
                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
        '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 AiTestMetric = await
            client.ai.tests.testFramework.v1.metrics.update('id', {
              name: 'name',
            });


            console.log(AiTestMetric.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
            )
            ai_test_metric = client.ai.tests.test_framework.v1.metrics.update(
                id="id",
                name="name",
            )
            print(ai_test_metric.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\tmetric, err := client.AI.Tests.TestFramework.V1.Metrics.Update(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\ttelnyx.AITestTestFrameworkV1MetricUpdateParams{\n\t\t\tName: telnyx.String(\"name\"),\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", metric.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.metrics.MetricUpdateParams;


            public final class Main {
                private Main() {}

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

                    MetricUpdateParams params = MetricUpdateParams.builder()
                        .name("name")
                        .build();
                    var response = client.ai().tests().testFramework().v1().metrics().update("id", params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


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


            ai_test_metric =
            telnyx.ai.tests.test_framework.v1.metrics.update("id", name: "name")


            puts(ai_test_metric)
        - 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 {
              $ai_test_metric = $client->ai->tests->testFramework->v1->metrics->update(
                'id',
                name: 'name',
              );

              var_dump($ai_test_metric);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:tests:test-framework:v1:metrics update \
              --api-key 'My API Key' \
              --id id \
              --name name
components:
  schemas:
    UpdateAiTestMetricRequest:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        type:
          type: string
          description: 'How the metric is evaluated: custom_code or llm_judge.'
        eval_type:
          type: string
          description: >-
            What the metric scores: numeric, continuous_qualitative, or
            binary_workflow_adherence.
        prompt:
          type: string
          description: Judge prompt used by llm_judge metrics.
        enum_values:
          type: array
          items:
            type: string
        agents:
          type: array
          items:
            type: integer
        add_to_new_agents:
          type:
            - boolean
            - 'null'
        simulation_enabled:
          type: boolean
        observability_enabled:
          type: boolean
        sampling_enabled:
          type: boolean
        audio_enabled:
          type: boolean
        display_order:
          type: integer
      example:
        name: Escalates on refund denial
        prompt: >-
          Score the assistant's escalation behaviour between 0.0 and 1.0,
          considering tone.
        audio_enabled: true
    AiTestMetric:
      type: object
      properties:
        id:
          type: integer
        slug:
          type:
            - string
            - 'null'
          description: Stable identifier of a built-in metric.
        project:
          type:
            - integer
            - 'null'
        agent:
          type:
            - integer
            - 'null'
        agents:
          type: array
          items:
            type: integer
          description: Test agent IDs the metric is attached to.
        agent_names:
          type: array
          items:
            type: string
        name:
          type: string
        description:
          type: string
        function_name:
          type:
            - string
            - 'null'
          description: Built-in evaluation function used by custom_code metrics.
        type:
          type: string
          description: 'How the metric is evaluated: custom_code or llm_judge.'
        eval_type:
          type: string
          description: >-
            What the metric scores: numeric, continuous_qualitative, or
            binary_workflow_adherence.
        enum_values:
          type: array
          items:
            type: string
          description: Allowed values for qualitative enum metrics.
        audio_enabled:
          type: boolean
        observability_enabled:
          type: boolean
        simulation_enabled:
          type: boolean
        sampling_enabled:
          type: boolean
        sample_rate:
          type:
            - number
            - 'null'
        prompt:
          type: string
          description: Judge prompt used by llm_judge metrics.
        display_order:
          type: integer
        evaluation_trigger:
          type: string
        trigger_type:
          type: string
        evaluation_trigger_prompt:
          type: string
        evaluation_trigger_custom_code:
          type: string
        priority_assignment_prompt:
          type: string
        configuration:
          type:
            - object
            - 'null'
          additionalProperties: true
        overall_score:
          type:
            - number
            - string
        total_score:
          type:
            - number
            - string
        kb_file_ids:
          type: array
          items:
            type: integer
        knowledge_base_files:
          type: array
          items:
            type: string
        metric_cost:
          type: number
        alert_type:
          type: string
        significant_change_alert_status:
          type: string
        significant_change_alert_direction:
          type: string
        window_size:
          type: integer
          description: Sliding window size the alert status is computed over.
        std_multiplier:
          type: number
          description: Standard-deviation multiplier for significant-change alerts.
        ewma_alpha:
          type: number
          description: Smoothing factor for the alert trend.
        add_to_new_agents:
          type:
            - boolean
            - 'null'
          description: >-
            Whether the metric is attached to newly created test agents by
            default.
        alert_filters:
          type:
            - object
            - 'null'
          additionalProperties: true
        uses_llm_judge:
          type: boolean
        user_defined:
          type: boolean
      required:
        - id
        - name
        - type
        - eval_type
      example:
        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
    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

````