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

# LMUnit

> Given a `query`, `response`, and a `unit_test`, return the response's `score` on the unit test on a 5-point continuous scale. The total input cannot exceed 7000 tokens.

See a code example in [our blog post](https://contextual.ai/news/lmunit/). Email [lmunit-feedback@contextual.ai](mailto:lmunit-feedback@contextual.ai) with any feedback or questions.

>🚀 Obtain an LMUnit API key by completing [this form](https://contextual.ai/request-lmunit-api/)



## OpenAPI

````yaml api-reference/openapi.json post /lmunit
openapi: 3.1.0
info:
  title: Endpoints
  version: '1.0'
servers:
  - url: https://api.contextual.ai/v1
security:
  - BearerAuth: []
paths:
  /lmunit:
    post:
      tags:
        - /lmunit
      summary: LMUnit
      description: >-
        Given a `query`, `response`, and a `unit_test`, return the response's
        `score` on the unit test on a 5-point continuous scale. The total input
        cannot exceed 7000 tokens.


        See a code example in [our blog
        post](https://contextual.ai/news/lmunit/). Email
        [lmunit-feedback@contextual.ai](mailto:lmunit-feedback@contextual.ai)
        with any feedback or questions.


        >🚀 Obtain an LMUnit API key by completing [this
        form](https://contextual.ai/request-lmunit-api/)
      operationId: lmunit_lmunit_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LMUnitRequestV1'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LMUnitResponseV1'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    LMUnitRequestV1:
      properties:
        query:
          type: string
          title: Query
          description: The prompt to which the model responds
        response:
          type: string
          title: Response
          description: The model response to evaluate
        unit_test:
          type: string
          title: Unit Test
          description: >-
            A natural language statement or question against which to evaluate
            the response
      additionalProperties: false
      type: object
      required:
        - query
        - response
        - unit_test
      title: LMUnitRequestV1
      description: LMUnit input request object.
    LMUnitResponseV1:
      properties:
        score:
          type: number
          title: Score
          description: >-
            The response is scored on a continuous scale from 1 to 5 on the unit
            test. The discrete scores 1, 2, 3, 4, and 5 roughly correspond to
            "Strongly fails," "Fails," "Neutral," "Passes," and "Strongly
            passes," respectively.
      type: object
      required:
        - score
      title: LMUnitResponseV1
      description: LMUnit result object.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````