Contextual AI LMUnit API

Evaluate model responses with natural-language unit tests.

Operations 1

POST /lmunit LMUnit #

Documentation

Specifications

Other Resources

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/contextual-ai:contextual-ai-lmunit-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

contextual-ai-lmunit-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Contextual Ai /lmunit API
  version: '1.0'
  description: 'Operations tagged /lmunit across 2 of this provider''s published API definitions: contextual-ai-openapi.json, contextual-ai-openapi.yml. Each path carries the servers of the definition it was published in.'
servers:
- url: https://api.contextual.ai/v1
tags:
- name: /lmunit
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. Email lmunit-feedback@contextual.ai with any feedback or questions.


        >🚀 Obtain an LMUnit API key by completing this form'
      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'
      security:
      - BearerAuth: []
    servers:
    - url: https://api.contextual.ai/v1
components:
  schemas:
    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
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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.
    LMUnitRequest:
      type: object
      required:
      - query
      - response
      - unit_test
      properties:
        query:
          type: string
          description: The prompt to which the model responds.
        response:
          type: string
          description: The model response to evaluate.
        unit_test:
          type: string
          description: Natural-language statement to evaluate the response against.
    HTTPValidationError_2:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorDetail'
    LMUnitResponse:
      type: object
      properties:
        score:
          type: number
          minimum: 1
          maximum: 5
          description: Continuous score from 1 (strongly fails) to 5 (strongly passes).
    ValidationErrorDetail:
      type: object
      properties:
        loc:
          type: array
          items:
            oneOf:
            - type: string
            - type: integer
        msg:
          type: string
        type:
          type: string
  responses:
    ValidationError:
      description: Validation error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/HTTPValidationError_2'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
    bearerAuth:
      type: http
      scheme: bearer
      description: Contextual AI API key supplied as a Bearer token.
x-refined-from:
- contextual-ai-openapi.json
- contextual-ai-openapi.yml