{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://api-evangelist.com/schemas/mathpix/mathpix-image-result-schema.json",
  "title": "Mathpix Image OCR Result",
  "description": "Schema for the response returned by POST /v3/text. Covers Mathpix Markdown plus optional styled LaTeX, HTML, structured data, line- and word-level segmentation, and confidence metrics.",
  "type": "object",
  "properties": {
    "request_id": {
      "type": "string",
      "description": "Unique identifier for debugging."
    },
    "text": {
      "type": "string",
      "description": "Recognized content in Mathpix Markdown."
    },
    "latex_styled": {
      "type": "string",
      "description": "Styled LaTeX equivalent of the recognized math."
    },
    "html": {
      "type": "string",
      "description": "HTML rendering of the recognized content."
    },
    "data": {
      "type": "array",
      "description": "Structured data extracted from the image (tables, equations).",
      "items": {
        "type": "object",
        "properties": {
          "type": {"type": "string"},
          "value": {"type": "string"}
        },
        "additionalProperties": true
      }
    },
    "confidence": {
      "type": "number",
      "description": "Probability of 100% accuracy in the range 0.0 - 1.0.",
      "minimum": 0,
      "maximum": 1
    },
    "confidence_rate": {
      "type": "number",
      "description": "Output quality confidence in the range 0.0 - 1.0.",
      "minimum": 0,
      "maximum": 1
    },
    "is_printed": {"type": "boolean"},
    "is_handwritten": {"type": "boolean"},
    "auto_rotate_confidence": {"type": "number"},
    "auto_rotate_degrees": {
      "type": "integer",
      "enum": [0, 90, -90, 180]
    },
    "image_height": {"type": "integer"},
    "image_width": {"type": "integer"},
    "line_data": {
      "type": "array",
      "description": "Per-line segmentation when include_line_data=true.",
      "items": {
        "type": "object",
        "properties": {
          "type": {"type": "string"},
          "subtype": {"type": "string"},
          "cnt": {
            "type": "array",
            "items": {"type": "array", "items": {"type": "number"}}
          },
          "included": {"type": "boolean"},
          "is_printed": {"type": "boolean"},
          "is_handwritten": {"type": "boolean"},
          "text": {"type": "string"}
        },
        "additionalProperties": true
      }
    },
    "word_data": {
      "type": "array",
      "description": "Per-word segmentation when include_word_data=true.",
      "items": {"type": "object", "additionalProperties": true}
    },
    "version": {"type": "string"},
    "error": {"type": "string"}
  },
  "additionalProperties": false
}
