> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vlm.run/llms.txt
> Use this file to discover all available pages before exploring further.

# rednote-hilab/dots.mocr

> Document layout parsing and OCR with Markdown output.

Document layout + OCR (vLLM). Accepts one `image_url` or a `document_url` PDF; no
text-only input. Default method: `markdown`. `parse_layout*` emit layout
regions; `ocr` / `markdown` emit strings.

## Output by method

| Method              | Payload kind | Image `content.object`                | Payload                                            |
| ------------------- | ------------ | ------------------------------------- | -------------------------------------------------- |
| `markdown`          | markdown     | none                                  | Reading-order Markdown string (default)            |
| `ocr`               | markdown     | none                                  | Plain OCR text                                     |
| `parse_layout`      | json         | `dots_mocr.parse_layout.regions`      | Region items with `bbox_xywh`, `label`, `text`     |
| `parse_layout_only` | json         | `dots_mocr.parse_layout_only.regions` | Region items with `bbox_xywh` and `label`, no text |

The payload kind is the same for an image and for each page of a PDF. Text mode
emits the payload alone for one image, and one `<document>` / `<page>` block per
PDF, each page declaring its kind in `format`. In JSON mode an image `content` is
the tagged container above, and a document page `content` is always
`document.page.blocks`. Coordinates are normalized 0-1 at `precision` decimals
(default 4). See [Methods & Response Format](/gateway/methods).

* `markdown`: reading-order Markdown page output. (default)
* `parse_layout`: structured layout parse with text for tables, figures, and
  reading order.
* `parse_layout_only`: layout regions and bounding boxes without transcribed text.
* `ocr`: plain OCR text extraction.

## Request

<CodeGroup>
  ```python Python [expandable] theme={"theme":{"light":"github-light","dark":"dark-plus"}}
  from openai import OpenAI

  client = OpenAI(
      base_url="https://gateway.vlm.run/v1/openai",
      api_key="<VLMRUN_API_KEY>",
  )

  response = client.chat.completions.create(
      model="rednote-hilab/dots.mocr",
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "document_url",
                      "document_url": {
                          "url": "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/finance.sec-filings/tsla-8k.pdf"
                      },
                  },
              ],
          }
      ],
      extra_body={"method": "markdown"},
  )

  print(response.choices[0].message.content)
  ```

  ```bash cURL [expandable] theme={"theme":{"light":"github-light","dark":"dark-plus"}}
  curl https://gateway.vlm.run/v1/openai/chat/completions \
    -X POST \
    -H "Authorization: Bearer $VLMRUN_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "rednote-hilab/dots.mocr",
      "method": "markdown",
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "document_url",
              "document_url": {
                "url": "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/finance.sec-filings/tsla-8k.pdf"
              }
            }
          ]
        }
      ]
    }'
  ```
</CodeGroup>

## Response

<Tabs>
  <Tab title="Text mode">
    One `<document>` block per PDF, one `<page>` block per page. A failed page is
    self-closing, with `status="error"` and no body:

    ```text theme={"theme":{"light":"github-light","dark":"dark-plus"}}
    <document file_name="tsla-8k.pdf" file_hash="sha256:1b7f…" file_bytes="182417" mimetype="application/pdf" num_pages="2" dpi="72">
    <page page_index="0" format="markdown" page_width="992" page_height="1400">
    # Annual Report 2024

    ## Overview
    The company reported revenue of $1.2M.
    </page>
    <page page_index="1" format="markdown" page_width="992" page_height="1400" status="error"/>
    </document>
    ```

    With `method="parse_layout"` each page body is the block container instead,
    and the page carries `format="json"`.
  </Tab>

  <Tab title="JSON mode">
    One document entry; each page's `content` is one Markdown block. A failed page
    carries `"status": "error"` and no `content`:

    ```json theme={"theme":{"light":"github-light","dark":"dark-plus"}}
    {
      "model": "rednote-hilab/dots.mocr",
      "method": "markdown",
      "data": [
        {
          "object": "document",
          "file_name": "tsla-8k.pdf",
          "file_hash": "sha256:1b7f...",
          "file_bytes": 182417,
          "mimetype": "application/pdf",
          "num_pages": 2,
          "dpi": 72,
          "pages": [
            {
              "object": "document.page",
              "page_index": 0,
              "page_width": 992,
              "page_height": 1400,
              "content": {
                "object": "document.page.blocks",
                "items": [
                  {"index": 0, "text": "# Annual Report 2024\n\n## Overview\nThe company reported revenue of $1.2M."}
                ]
              }
            },
            {"object": "document.page", "page_index": 1, "page_width": 992, "page_height": 1400, "status": "error"}
          ]
        }
      ]
    }
    ```
  </Tab>

  <Tab title="JSON mode (parse_layout)">
    With `method="parse_layout"`, each page's blocks carry the geometry:

    ```json theme={"theme":{"light":"github-light","dark":"dark-plus"}}
    {
      "object": "document.page",
      "page_index": 0,
      "page_width": 992,
      "page_height": 1400,
      "content": {
        "object": "document.page.blocks",
        "items": [
          {"index": 0, "bbox_xywh": [0.0343, 0.0143, 0.1774, 0.0343], "label": "title", "text": "Annual Report 2024"},
          {"index": 1, "bbox_xywh": [0.0343, 0.0857, 0.6048, 0.4286], "label": "table", "text": "| Item | Qty |\n| --- | --- |"}
        ]
      }
    }
    ```

    On an image the same request returns
    `{"object": "dots_mocr.parse_layout.regions", "items": [...]}`.
  </Tab>
</Tabs>

To get the structured layout regions instead (bounding boxes + labels), set
`method="parse_layout"`; see the output-by-method table above.
