---
title: "Layout Parsing"
method: POST
path: "/paas/v4/layout_parsing"
---

# Layout Parsing

`POST /paas/v4/layout_parsing`

Use the [GLM-OCR](/guides/vlm/glm-ocr) model to parse the layout of documents and images and extract text content. Support OCR recognition of images and PDF documents, returning detailed layout information and visualization results.

## Request body

- LayoutParsingRequest
  - `model` 'glm-ocr', required — Model code: `glm-ocr`
  - `file` string, required — Image or PDF document to be recognized, supports URL and base64. Supported image formats: PDF, JPG, PNG. Single image ≤10MB, PDF ≤50MB, maximum support 30 pages
  - `return_crop_images` boolean — Whether to return screenshot information
  - `need_layout_visualization` boolean — Whether to return detailed layout image result information
  - `start_page_id` integer — Start page number for parsing when PDF is provided
  - `end_page_id` integer — End page number for parsing when PDF is provided
  - `request_id` string — Passed by the user side, needs to be unique; used to distinguish each request, 6–64 characters. If not provided by the user side, the platform will generate one by default.
  - `user_id` string — Unique ID for the end user, 6–128 characters. Avoid using sensitive information.

## Response `200`

Business processing successful

- LayoutParsingResponse
  - `id` string, required — Task ID
  - `created` integer, required — Request creation time, Unix timestamp in seconds
  - `model` string, required — Model name
  - `md_results` string — Recognition result in Markdown format
  - `layout_details` array[] — Detailed layout information
    - LayoutDetail[]
      - `index` integer, required — Element index
      - `label` 'image' | 'text' | 'formula' | 'table', required — Element type: image for images, text for text content, formula for inline formulas, table for tables
      - `bbox_2d` number[] — Normalized element coordinates [x1,y1,x2,y2]
      - `content` string — Element content (text / image URL / table HTML)
      - `height` integer — Page height
      - `width` integer — Page width
  - `layout_visualization` string[] — Recognition result image URLs
  - `data_info` DataInfo — Document basic information
    - `num_pages` integer, required — Total number of document pages
    - `pages` PageInfo[] — Document page count information
      - `width` integer, required — Page width
      - `height` integer, required — Page height
  - `usage` object — Token usage statistics returned when the model call ends.
    - `prompt_tokens` number — Number of tokens in user input
    - `completion_tokens` number — Number of output tokens
    - `prompt_tokens_details` object
      - `cached_tokens` number — Number of tokens served from cache
    - `total_tokens` integer — Total number of tokens
  - `request_id` string — Request ID

## Other responses

- `default` — Request failed.

---

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