{
  "openapi": "3.1.0",
  "info": {
    "title": "OCR MLX API",
    "description": "OCR tool using Nougat models and LLM vision capabilities",
    "version": "1.0.0"
  },
  "paths": {
    "/llm/ocr": {
      "post": {
        "tags": [
          "llm"
        ],
        "summary": "Perform OCR on an image using LLM vision capabilities",
        "description": "Extract text from images using Large Language Models with vision capabilities like GPT-4 Vision",
        "operationId": "llm-llm_ocr",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LLMOCRRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/ocr": {
      "post": {
        "tags": [
          "ocr"
        ],
        "summary": "Perform OCR on an image or PDF",
        "operationId": "ocr-ocr",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OCRRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "tags": [
          "health"
        ],
        "summary": "Health check endpoint",
        "operationId": "health-health",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/shutdown": {
      "get": {
        "tags": [
          "shutdown"
        ],
        "summary": "Shutdown endpoint",
        "operationId": "shutdown-shutdown",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/logs": {
      "get": {
        "tags": [
          "logs"
        ],
        "summary": "Get current log file contents",
        "operationId": "logs-get_logs",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "LLMOCRRequest": {
        "properties": {
          "filename": {
            "type": "string",
            "title": "Filename",
            "description": "Filename or image data",
            "default": ""
          },
          "api_key": {
            "type": "string",
            "title": "Api Key",
            "description": "API key for the LLM service",
            "default": ""
          },
          "model": {
            "type": "string",
            "title": "Model",
            "description": "Model name to use",
            "default": "gpt-4.1-mini",
            "examples": [
              "gpt-4.1-mini",
              "gpt-4o",
              "gpt-4o-mini"
            ]
          },
          "endpoint_url": {
            "type": "string",
            "title": "Endpoint Url",
            "description": "LLM API endpoint URL",
            "default": "https://api.openai.com/v1/chat/completions"
          },
          "max_tokens": {
            "type": "integer",
            "maximum": 4096,
            "minimum": 1,
            "title": "Max Tokens",
            "description": "Maximum tokens in response",
            "default": 1000
          },
          "temperature": {
            "type": "number",
            "maximum": 2,
            "minimum": 0,
            "title": "Temperature",
            "description": "Sampling temperature",
            "default": 0
          },
          "prompt": {
            "type": "string",
            "title": "Prompt",
            "description": "Custom prompt for text extraction",
            "default": "You are an OCR model.\nI will give you an image of a document, sign, or printed text.\nYour task is to extract the visible text exactly as it appears in the image.\n- Preserve line breaks and formatting where possible.\n- Do not add or remove any words.\n- Output text only — no explanations, no commentary.\nHere is the image:\n            "
          }
        },
        "type": "object",
        "title": "LLMOCRRequest"
      },
      "OCRRequest": {
        "properties": {
          "filename": {
            "type": "string",
            "title": "Filename",
            "description": "Filename",
            "default": ""
          },
          "model": {
            "type": "string",
            "title": "Model",
            "description": "Model name or path",
            "default": "facebook/nougat-small",
            "examples": [
              "facebook/nougat-small",
              "facebook/nougat-large"
            ]
          },
          "temperature": {
            "type": "number",
            "maximum": 1,
            "minimum": 0,
            "title": "Temperature",
            "description": "Sampling temperature",
            "default": 0
          },
          "top_p": {
            "type": "number",
            "maximum": 1,
            "minimum": 0,
            "title": "Top P",
            "description": "Top-p sampling threshold",
            "default": 0
          },
          "repetition_penalty": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Repetition Penalty",
            "description": "Repetition penalty"
          },
          "padding": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Padding",
            "description": "Padding"
          }
        },
        "type": "object",
        "title": "OCRRequest"
      },
      "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"
      }
    }
  }
}