---
title: "Process Ocr"
method: POST
path: "/ocr"
tags: ["ocr"]
---

# Process Ocr

`POST /ocr`

Process a document using OCR (Optical Character Recognition).

This endpoint extracts text and structure from documents (PDFs, images) and
returns the content in markdown format. It supports multiple document types
and can extract images embedded within documents.

The extracted markdown preserves document structure including headings,
tables, lists, and other formatting.

## Request body

- OCRRequestModel — Request model for OCR processing.
  - `model` string, required — The OCR model to use
  - `document` OCRDocument, required — Document specification for OCR processing.
    - `type` string, required — Document type: 'document_url', 'image_url', or 'base64'
    - `document_url` string, nullable — URL to the document (PDF or image) to process. Use with type='document_url'
    - `image_url` string, nullable — URL to an image to process. Use with type='image_url'
    - `document_name` string, nullable — Name of the document. Use with type='base64'
    - `content` string, nullable — Base64-encoded content of the document. Use with type='base64'
  - `pages` integer[], nullable — Specific page indices to process (0-based). If not specified, all pages are processed.
  - `include_image_base64` boolean — Whether to include base64-encoded images in the response
  - `image_limit` integer, nullable — Maximum number of images to extract per page
  - `image_min_size` integer, nullable — Minimum size (width or height in pixels) for images to be included
  - `mistral_extra` MistralOCRExtra — Mistral-specific OCR parameters.
    - `extract_header` boolean, nullable — Whether to extract header content from pages
    - `extract_footer` boolean, nullable — Whether to extract footer content from pages
    - `table_format` string, nullable — Format for extracted tables: 'markdown' or 'html'
    - `bbox_annotation_format` object, nullable — JSON schema for structured bounding box extraction
    - `document_annotation_format` object, nullable — JSON schema for structured document extraction
  - `docling_extra` DoclingOCRExtra — Docling-specific OCR parameters for document parsing with layout analysis.
    - `output_format` string, nullable — Output format: 'markdown' (default) returns clean text with tables, 'json' includes bounding boxes and full document structure.
    - `ocr_engine` string, nullable — OCR engine: null (auto-select, typically RapidOCR), 'easyocr' (good multilingual support), or 'tesseract' (fast, many languages).
    - `lang` string[], nullable — OCR language(s) to recognise, as ISO 639-1 two-letter codes (e.g. 'sv', 'en', 'de', 'da', 'no', 'fi', 'is'). Opper maps these to the chosen engine internally, so the same codes work for any engine. Requires ocr_engine 'tesseract' or 'easyocr' (the auto/RapidOCR engine ignores it). Pass several for mixed-language documents. Note: 'fi' (Finnish) is only available with 'tesseract'. Defaults to the engine's own default (English) when omitted.
    - `force_ocr` boolean, nullable — Force OCR on all pages even if text is extractable. Useful for scanned PDFs with embedded but incorrect text layers.
    - `table_mode` string, nullable — Table extraction mode: 'fast' (default) for speed, 'accurate' for complex tables with merged cells or nested structures.
    - `images_scale` number, nullable — Scale factor for extracted images. Default is 1.0. Use 2.0 or higher for better resolution (slower processing).
    - `do_formula_enrichment` boolean, nullable — Enable mathematical formula detection and LaTeX extraction. Equations are converted to LaTeX notation in the output.
    - `do_code_enrichment` boolean, nullable — Enable code block detection and formatting. Code snippets are wrapped in markdown code fences with language detection.

## Response `200`

Successful Response

- OCRResponseModel — Response model for OCR processing.
  - `id` string, required — Unique identifier for this OCR request
  - `pages` OCRPageResult[], required — Processed page results
    - `index` integer, required — Page index (0-based)
    - `markdown` string, required — Extracted text in markdown format
    - `dimensions` OCRPageDimensions — Dimensions of a processed page.
      - `dpi` integer, nullable — DPI of the page
      - `height` integer, nullable — Height in pixels
      - `width` integer, nullable — Width in pixels
    - `images` OCRPageImage[], nullable — Extracted images from the page
      - `id` string, required — Unique identifier for the image
      - `top_left_x` integer, nullable — X coordinate of top-left corner
      - `top_left_y` integer, nullable — Y coordinate of top-left corner
      - `bottom_right_x` integer, nullable — X coordinate of bottom-right corner
      - `bottom_right_y` integer, nullable — Y coordinate of bottom-right corner
      - `image_base64` string, nullable — Base64-encoded image data (if include_image_base64=True)
    - `elements` OCRPageElement[], nullable — Document elements with bounding boxes and labels (only returned when using Docling with output_format='json')
      - `type` string, required — Element type: 'text', 'table', or 'picture'
      - `label` string, nullable — Element label (e.g. 'title', 'section_header', 'page_header', 'page_footer', 'caption', 'footnote', 'formula', 'text')
      - `text` string, nullable — Text content (for text elements)
      - `bbox` object, nullable — Bounding box with l, t, r, b coordinates
      - `data` object, nullable — Table data as dictionary (for table elements)
  - `model` string, required — The model used for OCR
  - `usage_info` OCRUsageInfo, required — Usage information for OCR processing.
    - `pages_processed` integer, required — Number of pages processed
    - `doc_size_bytes` integer, nullable — Size of the document in bytes
    - `processing_time_seconds` number, nullable — Total processing time in seconds
    - `time_per_page_seconds` number, nullable — Average processing time per page in seconds
    - `applied_settings` object, nullable — Settings used for processing
  - `cost` OCRCost — Cost information for OCR processing.
    - `generation` number, required — Cost of the OCR request in USD
    - `platform` number, required — Platform fee in USD (percentage of generation cost)
    - `total` number, required — Total cost in USD (generation + platform)

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `402` — Payment Required (out of credits)
- `404` — Not Found
- `422` — Request Validation Error

---

[API](https://skmtc.dev/opper/apis/opper-api-v2.md) · [All operations](https://skmtc.dev/opper/apis/opper-api-v2/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/opper/opper-api-v2/revisions/d3ccdaa15678/schema)
