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

# Model Comparison (beta)

> Compare outputs from two different models on the same prompt. Returns both responses side-by-side with basic metadata. Pricing is based on the underlying models used.



## OpenAPI

````yaml /openapi.json post /api/v1/compare
openapi: 3.1.0
info:
  title: NinjaChat API
  version: 1.0.0
  description: >-
    Access 40+ AI models through a unified API — chat, image generation, video
    generation, and web search. One API key, one endpoint per type, just change
    the `model` parameter.
servers:
  - url: https://www.ninjachat.ai
security:
  - bearerAuth: []
paths:
  /api/v1/compare:
    post:
      tags:
        - Endpoints
      summary: Model Comparison (beta)
      description: >-
        Compare outputs from two different models on the same prompt. Returns
        both responses side-by-side with basic metadata. Pricing is based on the
        underlying models used.
      operationId: compareModels
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model_a
                - model_b
                - prompt
              properties:
                model_a:
                  type: string
                  description: First model ID to compare (e.g. gpt-5, claude-sonnet-4.6).
                model_b:
                  type: string
                  description: Second model ID to compare.
                prompt:
                  type: string
                  minLength: 1
                  maxLength: 4000
                  description: The input prompt to send to both models.
                temperature:
                  type: number
                  minimum: 0
                  maximum: 2
                  default: 0.7
                  description: Optional sampling temperature applied to both models.
            example:
              model_a: gpt-5
              model_b: claude-sonnet-4.6
              prompt: >-
                Explain the difference between supervised and unsupervised
                learning.
      responses:
        '200':
          description: Comparison results from both models.
          content:
            application/json:
              schema:
                type: object
                properties:
                  model_a:
                    type: object
                    properties:
                      id:
                        type: string
                      output:
                        type: string
                  model_b:
                    type: object
                    properties:
                      id:
                        type: string
                      output:
                        type: string
                  cost:
                    $ref: '#/components/schemas/Cost'
                  metadata:
                    type: object
                    properties:
                      latency_ms:
                        type: integer
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Insufficient credits.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    Cost:
      type: object
      properties:
        this_request:
          type: string
          example: $0.006
          description: Cost of this request.
    ErrorResponse:
      type: object
      description: >-
        OpenAI-compatible error. The top-level `message`, `code`, and
        `request_id` mirror fields inside `error` for convenience.
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error description.
            type:
              type: string
              description: >-
                Error category: invalid_request_error, authentication_error,
                rate_limit_error, insufficient_quota, or api_error.
            code:
              type: string
              description: Machine-readable error code.
            param:
              type: string
              nullable: true
              description: The request parameter that caused the error, if any.
        message:
          type: string
          description: Same as error.message.
        code:
          type: string
          description: Same as error.code.
        request_id:
          type: string
          description: Unique request ID, useful when contacting support.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key starting with nj_sk_

````