openapi: 3.1.0
info:
  title: NVIDIA NIM for Image OCR
  version: 1.0.0
  description: NVIDIA NIM for Image OCR
paths:
  /v1/infer:
    post:
      summary: Inference Endpoint
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OCRRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OCRResponse'
        '503':
          description: Service not ready
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /v1/health/ready:
    get:
      summary: Readiness Endpoint
      responses:
        '200':
          description: Service ready
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthReadyResponse'
        '503':
          description: Service not ready
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthReadyResponse'
  /v1/health/live:
    get:
      summary: Liveness Endpoint
      responses:
        '200':
          description: Service live
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthLiveResponse'
        '503':
          description: Service not live
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthLiveResponse'
components:
  schemas:
    OCRRequest:
      $defs:
        Image:
          properties:
            type:
              const: image_url
              default: image_url
              title: Type
              type: string
            url:
              description: The URL of the image to process.
              title: Url
              type: string
          required:
          - url
          title: Image
          type: object
        MergeLevel:
          enum:
          - word
          - sentence
          - paragraph
          title: MergeLevel
          type: string
      properties:
        input:
          items:
            $ref: '#/components/schemas/OCRRequest/$defs/Image'
          minItems: 1
          title: Input
          type: array
        merge_levels:
          anyOf:
          - items:
              $ref: '#/components/schemas/OCRRequest/$defs/MergeLevel'
            type: array
          - type: 'null'
          default: null
          description: The level at which to merge the OCR results for each image.
          title: Merge Levels
      required:
      - input
      title: OCRRequest
      type: object
    OCRResponse:
      $defs:
        OCRResponseItem:
          properties:
            index:
              title: Index
              type: integer
            text_detections:
              items:
                $ref: '#/components/schemas/OCRResponse/$defs/TextDetection'
              title: Text Detections
              type: array
          required:
          - index
          - text_detections
          title: OCRResponseItem
          type: object
        Point:
          properties:
            x:
              title: X
              type: number
            y:
              title: Y
              type: number
          required:
          - x
          - y
          title: Point
          type: object
        Polygon:
          properties:
            points:
              items:
                $ref: '#/components/schemas/OCRResponse/$defs/Point'
              title: Points
              type: array
          required:
          - points
          title: Polygon
          type: object
        Text:
          properties:
            text:
              title: Text
              type: string
            confidence:
              anyOf:
              - type: number
              - type: 'null'
              default: null
              title: Confidence
          required:
          - text
          title: Text
          type: object
        TextDetection:
          properties:
            text_prediction:
              $ref: '#/components/schemas/OCRResponse/$defs/Text'
            bounding_box:
              $ref: '#/components/schemas/OCRResponse/$defs/Polygon'
          required:
          - text_prediction
          - bounding_box
          title: TextDetection
          type: object
        UsageInfo:
          properties:
            images_size_mb:
              title: Images Size Mb
              type: number
          required:
          - images_size_mb
          title: UsageInfo
          type: object
      properties:
        data:
          items:
            $ref: '#/components/schemas/OCRResponse/$defs/OCRResponseItem'
          title: Data
          type: array
        usage:
          $ref: '#/components/schemas/OCRResponse/$defs/UsageInfo'
      required:
      - data
      - usage
      title: OCRResponse
      type: object
    ErrorResponse:
      properties:
        error:
          title: Error
          type: string
      required:
      - error
      title: ErrorResponse
      type: object
    HealthReadyResponse:
      properties:
        ready:
          title: Ready
          type: boolean
      required:
      - ready
      title: HealthReadyResponse
      type: object
    HealthLiveResponse:
      properties:
        live:
          title: Live
          type: boolean
      required:
      - live
      title: HealthLiveResponse
      type: object
