---
title: "OCR"
method: POST
path: "/v1/ocr"
tags: ["ocr"]
---

# OCR

`POST /v1/ocr`

OCR

## Request body

- OCRRequest
  - `model` string, nullable, required
  - `document` union, required — Document to run OCR on
    - FileChunk
      - `type` 'file'
      - `file_id` string, uuid, required
    - DocumentURLChunk
      - `type` 'document_url'
      - `document_url` string, required
      - `document_name` string, nullable — The filename of the document
    - ImageURLChunk — {"type":"image_url","image_url":"data:image/png;base64,iVBORw0"}
      - `type` 'image_url'
      - `image_url` union, required
        - ImageURL
          - `url` string, required
          - `detail` 'low' | 'auto' | 'high'
        - string
  - `pages` union — Specific pages to process. Accepts a list of integers or a string of comma-separated numbers and ranges (e.g. '0,1,2' or '0-5' or '0,2-4'). Page numbers start from 0.
    - string
    - integer[]
  - `include_image_base64` boolean, nullable — Include image URLs in response
  - `image_limit` integer, nullable — Max images to extract
  - `image_min_size` integer, nullable — Minimum height and width of image to extract
  - `bbox_annotation_format` ResponseFormat — Specify the format that the model must output. By default it will use `{ "type": "text" }`. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ "type": "json_schema" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide.
    - `type` 'text' | 'json_object' | 'json_schema'
    - `json_schema` JsonSchema
      - `name` string, required
      - `description` string, nullable
      - `schema` object, required
      - `strict` boolean
  - `document_annotation_format` ResponseFormat — Specify the format that the model must output. By default it will use `{ "type": "text" }`. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ "type": "json_schema" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide.
    - `type` 'text' | 'json_object' | 'json_schema'
    - `json_schema` JsonSchema
      - `name` string, required
      - `description` string, nullable
      - `schema` object, required
      - `strict` boolean
  - `document_annotation_prompt` string, nullable — Optional prompt to guide the model in extracting structured output from the entire document. A document_annotation_format must be provided.
  - `table_format` 'markdown' | 'html', nullable
  - `extract_header` boolean — Extract the page header into the response's `header` field and remove it from the markdown content
  - `extract_footer` boolean — Extract the page footer into the response's `footer` field and remove it from the markdown content
  - `include_blocks` boolean — Return paragraph-level bounding boxes for all content blocks in the response
  - `confidence_scores_granularity` 'word' | 'page', nullable — Granularity for confidence scores: 'page' (aggregate only), 'word' (per-word scores). Defaults to None (no confidence scores) to keep response payload small.

## Response `200`

Successful Response

- OCRResponse
  - `pages` OCRPageObject[], required — List of OCR info for pages.
    - `index` integer, required — The page index in a pdf document starting from 0
    - `markdown` string, required — The markdown string response of the page
    - `images` OCRImageObject[], required — List of all extracted images in the page
      - `id` string, required — Image ID for extracted image in a page
      - `top_left_x` integer, nullable, required — X coordinate of top-left corner of the extracted image
      - `top_left_y` integer, nullable, required — Y coordinate of top-left corner of the extracted image
      - `bottom_right_x` integer, nullable, required — X coordinate of bottom-right corner of the extracted image
      - `bottom_right_y` integer, nullable, required — Y coordinate of bottom-right corner of the extracted image
      - `image_base64` string, nullable — Base64 string of the extracted image
      - `image_annotation` string, nullable — Annotation of the extracted image in json str
    - `tables` OCRTableObject[] — List of all extracted tables in the page
      - `id` string, required — Table ID for extracted table in a page
      - `content` string, required — Content of the table in the given format
      - `format` 'markdown' | 'html', required — Format of the table
      - `word_confidence_scores` OCRConfidenceScore[], nullable — Per-word confidence scores for the table content. Returned when confidence_scores_granularity is set to 'word'.
        - `text` string, required — The word or text segment
        - `confidence` number, required — Confidence score (0-1)
        - `start_index` integer, required — Start index of the text in the page markdown string
    - `hyperlinks` string[] — List of all hyperlinks in the page
    - `header` string, nullable — Header of the page
    - `footer` string, nullable — Footer of the page
    - `dimensions` OCRPageDimensions, required
      - `dpi` integer, required — Dots per inch of the page-image
      - `height` integer, required — Height of the image in pixels
      - `width` integer, required — Width of the image in pixels
    - `confidence_scores` OCRPageConfidenceScores — Confidence scores for an OCR page at various granularities. Note on page-level stats: - For 'page' granularity: average/minimum are computed from per-token exp(logprob). - For 'word' granularity: average/minimum are computed from per-word confidence, where each word's confidence is exp(mean(token_logprobs)) — a geometric mean over the word's subword tokens.
      - `word_confidence_scores` OCRConfidenceScore[] — Word-level confidence scores (populated only for 'word' granularity)
        - `text` string, required — The word or text segment
        - `confidence` number, required — Confidence score (0-1)
        - `start_index` integer, required — Start index of the text in the page markdown string
      - `average_page_confidence_score` number, required — Average confidence score for the page
      - `minimum_page_confidence_score` number, required — Minimum confidence score for the page
    - `blocks` union[], nullable — Paragraph-level bounding boxes for all content blocks in reading order (populated when include_blocks is True)
      - union
        - OCRTextBlock
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'text'
        - OCRListBlock
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'list'
        - OCRImageBlock
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'image'
          - `image_id` string, required — References the corresponding entry in OCRPageObject.images
        - OCRTableBlock
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'table'
          - `table_id` string, nullable — References the corresponding entry in OCRPageObject.tables, when tables are extracted
        - OCRTitleBlock
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'title'
        - OCREquationBlock
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'equation'
        - OCRCaptionBlock
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'caption'
        - OCRCodeBlock
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'code'
        - OCRReferencesBlock
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'references'
        - OCRAsideTextBlock
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'aside_text'
        - OCRHeaderBlock
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'header'
        - OCRFooterBlock
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'footer'
        - OCRSignatureBlock — Signature region. ``content`` is the transcribed name when legible, else ``""``.
          - `top_left_x` integer, required
          - `top_left_y` integer, required
          - `bottom_right_x` integer, required
          - `bottom_right_y` integer, required
          - `content` string, required — Text/markdown/html content of this block
          - `type` 'signature'
  - `model` string, required — The model used to generate the OCR.
  - `document_annotation` string, nullable — Formatted response in the request_format if provided in json str
  - `usage_info` OCRUsageInfo, required
    - `pages_processed` integer, required — Number of pages processed
    - `doc_size_bytes` integer, nullable — Document size in bytes

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/mistral/apis/mistral-ai-api.md) · [All operations](https://skmtc.net/mistral/apis/mistral-ai-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/mistral/mistral-ai-api/revisions/933c4ebdcd72/schema)
