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

# Create a new metric

> Add a new metric



## OpenAPI

````yaml post /metrics
openapi: 3.0.3
info:
  title: HoneyHive API
  version: 1.0.1
servers:
  - url: https://api.honeyhive.ai
security:
  - BearerAuth: []
paths:
  /metrics:
    post:
      tags:
        - Metrics
      summary: Create a new metric
      description: Add a new metric
      operationId: createMetric
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Metric'
      responses:
        '200':
          description: Metric created successfully
      x-codeSamples:
        - lang: python
          label: createMetric
          source: |-
            import honeyhive
            from honeyhive.models import components

            s = honeyhive.HoneyHive(
                bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
            )


            res = s.metrics.create_metric(request=components.Metric(
                name='<value>',
                task='<value>',
                type=components.MetricType.MODEL,
                description='Fully-configurable neutral framework',
                return_type=components.ReturnType.STRING,
            ))

            if res is not None:
                # handle response
                pass
        - lang: typescript
          label: createMetric
          source: >-
            import { HoneyHive } from "honeyhive";

            import { MetricType, ReturnTypeT } from
            "honeyhive/dist/models/components";


            async function run() {
              const sdk = new HoneyHive({
                bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
              });

              const res = await sdk.metrics.createMetric({
                name: "<value>",
                task: "<value>",
                type: MetricType.Model,
                description: "Fully-configurable neutral framework",
                returnType: ReturnTypeT.String,
                threshold: {},
              });

              if (res.statusCode == 200) {
                // handle response
              }
            }


            run();
components:
  schemas:
    Metric:
      type: object
      properties:
        name:
          type: string
          description: Name of the metric
        criteria:
          type: string
          description: Criteria for human metrics
        code_snippet:
          type: string
          description: Associated code block for the metric
        prompt:
          type: string
          description: Evaluator prompt for the metric
        task:
          type: string
          description: Name of the project associated with metric
        type:
          type: string
          enum:
            - custom
            - model
            - human
          description: Type of the metric - "custom", "model" or "human"
        description:
          type: string
          description: Short description of what the metric does
        enabled_in_prod:
          type: boolean
          description: Whether to compute on all production events automatically
        needs_ground_truth:
          type: boolean
          description: Whether a ground truth (on metadata) is required to compute it
        return_type:
          type: string
          enum:
            - boolean
            - float
            - string
          description: The data type of the metric value - "boolean", "float", "string"
        threshold:
          type: object
          properties:
            min:
              type: number
            max:
              type: number
          description: Threshold for numeric metrics to decide passing or failing in tests
        pass_when:
          type: boolean
          description: Threshold for boolean metrics to decide passing or failing in tests
        _id:
          type: string
          description: Unique idenitifier
        event_name:
          type: string
          description: Name of event that the metric is set to be computed on
        event_type:
          type: string
          description: Type of event that the metric is set to be computed on
      required:
        - name
        - task
        - type
        - description
        - return_type
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````