Contextual AI LMUnit API

Evaluate model responses with natural-language unit tests.

GitHub OpenAPI

Operations 1

Each operation below carries the questions people ask an LLM about it and the instructions they give an agent to run it. Generated by API Evangelist overlay

POST /lmunit Score a model response against a unit test · LMUnit #
Ask an LLM
“How do I score a model's response against a unit test?”
“What is the token limit for an LMUnit evaluation?”
Tell an agent
Score response {response} to query {query} against unit test {unit_test}.
Evaluate {response} on {unit_test} for prompt {query}.

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. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. 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: Endpoints /lmunit API
  version: '1.0'
servers:
- url: https://api.contextual.ai/v1
security:
- BearerAuth: []
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'
components:
  schemas:
    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.
    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.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key