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

# Compare image and vector pairs without storing embeddings



## OpenAPI

````yaml /openapi/deepface.openapi.yaml post /compare
openapi: 3.1.0
info:
  title: deepface.dev API
  version: v1
  summary: Managed API for face verification, embeddings, and vector comparison.
  description: >
    Canonical OpenAPI contract for the public deepface.dev gateway. This covers
    the public surface: health, capabilities, verify, represent, and compare.
  license:
    name: Proprietary
    url: https://deepface.dev/terms
servers:
  - url: https://api.deepface.dev
    description: Production gateway
security:
  - BearerAuth: []
  - ApiKeyHeader: []
tags:
  - name: Service
    description: Read-only service metadata and health routes.
  - name: Compute
    description: Authenticated face verification and vector-comparison endpoints.
paths:
  /compare:
    post:
      tags:
        - Compute
      summary: Compare image and vector pairs without storing embeddings
      operationId: compareVectors
      parameters:
        - $ref: '#/components/parameters/RequestId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompareJsonRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CompareMultipartRequest'
      responses:
        '200':
          description: Compare result
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompareResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '422':
          $ref: '#/components/responses/NoFaceDetected'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
        '502':
          $ref: '#/components/responses/UpstreamError'
        '503':
          $ref: '#/components/responses/TemporaryCapacityError'
components:
  parameters:
    RequestId:
      in: header
      name: x-request-id
      required: false
      description: Optional UUID used for request tracing.
      schema:
        type: string
        format: uuid
  schemas:
    CompareJsonRequest:
      type: object
      required:
        - model_name
      properties:
        model_name:
          type: string
          maxLength: 200
          example: Facenet
        img:
          $ref: '#/components/schemas/ImageDataString'
        source_vector:
          type: array
          items:
            type: number
        vector:
          oneOf:
            - type: array
              items:
                type: number
            - $ref: '#/components/schemas/VectorList'
        target_vector:
          type: array
          items:
            type: number
        target_vectors:
          $ref: '#/components/schemas/VectorList'
        vectors:
          $ref: '#/components/schemas/VectorList'
        vector_b:
          type: array
          items:
            type: number
        distance_metric:
          type: string
          enum:
            - cosine
            - euclidean
            - euclidean_l2
          default: cosine
        metric:
          type: string
          enum:
            - cosine
            - euclidean
            - euclidean_l2
        threshold:
          type: number
        detector_backend:
          type: string
        enforce_detection:
          type: boolean
        align:
          type: boolean
        normalization:
          type: string
        face_index:
          type: integer
          default: 0
    CompareMultipartRequest:
      type: object
      required:
        - model_name
      properties:
        model_name:
          type: string
          maxLength: 200
        img:
          type: string
          format: binary
        source_vector:
          type: string
          description: JSON-encoded vector array.
        vector:
          type: string
          description: JSON-encoded vector array or vector list.
        target_vector:
          type: string
          description: JSON-encoded vector array.
        target_vectors:
          type: string
          description: JSON-encoded vector list.
        vectors:
          type: string
          description: JSON-encoded vector list.
        vector_b:
          type: string
          description: JSON-encoded vector array.
        distance_metric:
          type: string
          enum:
            - cosine
            - euclidean
            - euclidean_l2
        metric:
          type: string
          enum:
            - cosine
            - euclidean
            - euclidean_l2
        threshold:
          type: number
        detector_backend:
          type: string
        enforce_detection:
          type: boolean
        align:
          type: boolean
        normalization:
          type: string
        face_index:
          type: integer
    CompareResponse:
      type: object
      required:
        - model_name
        - metric
        - source
        - results
      properties:
        model_name:
          type: string
        metric:
          type: string
          enum:
            - cosine
            - euclidean
            - euclidean_l2
        threshold:
          oneOf:
            - type: number
            - type: 'null'
        source:
          $ref: '#/components/schemas/CompareSource'
        results:
          type: array
          items:
            $ref: '#/components/schemas/CompareResultItem'
        best_match:
          $ref: '#/components/schemas/CompareResultItem'
    ImageDataString:
      type: string
      description: >
        Base64 image payload or data URL. The managed API rejects images that
        exceed the active byte, request-size, or decoded pixel safety limits
        before forwarding work to the model runtime.
    VectorList:
      type: array
      items:
        oneOf:
          - type: array
            items:
              type: number
          - type: object
            properties:
              id:
                oneOf:
                  - type: string
                  - type: integer
              vector:
                type: array
                items:
                  type: number
            required:
              - vector
    CompareSource:
      type: object
      required:
        - type
        - vector_length
      properties:
        type:
          type: string
          enum:
            - image
            - vector
        vector_length:
          type: integer
        face_index:
          oneOf:
            - type: integer
            - type: 'null'
    CompareResultItem:
      type: object
      required:
        - index
        - distance
      properties:
        id:
          oneOf:
            - type: string
            - type: integer
            - type: 'null'
        index:
          type: integer
        distance:
          type: number
        match:
          type: boolean
      additionalProperties: false
    ErrorResponse:
      type: object
      description: >
        Gateway errors include `upstream_response_too_large` when the model
        response exceeds the configured gateway response-size limit.
      required:
        - error
      properties:
        error:
          type: string
        detail:
          type: string
  headers:
    RequestId:
      description: Request identifier echoed by the gateway.
      schema:
        type: string
        format: uuid
    RateLimitLimit:
      description: >-
        Maximum number of compute requests allowed per minute for the current
        account.
      schema:
        type: integer
    RateLimitRemaining:
      description: Remaining compute requests in the current rolling minute window.
      schema:
        type: integer
    RateLimitReset:
      description: Seconds until the current rate-limit window resets.
      schema:
        type: integer
  responses:
    BadRequest:
      description: >
        Invalid request payload, including malformed image data or image inputs
        that exceed the active byte or pixel safety limits.
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: >-
        Missing or invalid API key. If the bearer value is an unexpanded shell
        variable, the response detail explains how to quote the header.
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    PaymentRequired:
      description: Account does not meet the current credit policy
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NoFaceDetected:
      description: No usable face could be extracted from one of the provided images
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    RateLimited:
      description: Per-account rate limit exceeded
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
        Retry-After:
          schema:
            type: integer
          description: Seconds to wait before retrying.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalError:
      description: Unhandled server error
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    UpstreamError:
      description: Model server request failed
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    TemporaryCapacityError:
      description: >-
        Temporary billing-reservation, queue, concurrency, or model-tier
        availability pressure
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
        Retry-After:
          schema:
            type: integer
          description: Seconds to wait before retrying.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: Use your API key as a bearer token.
    ApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: Alternative header for API key authentication.

````