Extract document text
Extract text from documents or images as per-page Markdown with images and page usage.
/model/v1/ocr● SupportedRequest body
modelstring必填OCR model ID, for example glm-ocr.
Verified to take effect.
documentobject必填Choose document_url, image_url (HTTPS or data URL), or {type: file, file_id: string}.
Supports PDF data URLs, image_url and uploaded file_id; remote URLs must be downloadable.
▸ 展开子字段(5)
typestring必填Always `file`. Discriminator of the `type`-tagged union this object belongs to.
document_urlstring必填HTTPS or base64 data URL; required when type is document_url.
document_namestring可选Optional file name of the document, used by the provider for display.
image_urlstring必填HTTPS or base64 data URL; required when type is image_url.
file_idstring必填File ID owned by the authenticated tenant. The file_id read limit is 24 MiB (25165824 bytes; shared 96 MiB memory budget / 4); PNG/JPEG remain limited to 10 MiB. Larger files return 413: use HTTPS document_url for PDFs up to 50 MiB. Image pages must be [0].
pagesarray可选Zero-based page indices to process.
Zero-based page selection with deduplication; out-of-range pages error.
include_image_base64boolean可选◐ Partially supportedInclude extracted images as base64.
glm-ocr accepts false only; true returns 400.
table_formatstring可选◐ Partially supportedFormat for tables that are extracted separately: when set, tables come back in `tables` in this format and the page markdown keeps a link to each; when null they stay inline in the markdown. Router support (partial): glm-ocr accepts markdown or null only; html returns 400.
glm-ocr accepts markdown or null only; html returns 400.
extract_headerboolean可选○ UnsupportedWhether to extract page headers separately into `header`. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
Unsupported on glm-ocr; passing it returns 400.
extract_footerboolean可选○ UnsupportedWhether to extract page footers separately into `footer`. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
Unsupported on glm-ocr; passing it returns 400.
bbox_annotation_formatobject可选○ UnsupportedStructured image annotations; OCR requires json_schema. Availability depends on the model.
Unsupported on glm-ocr; passing it returns 400.
▸ 展开子字段(2)
typestring可选Response format type of the annotation.
json_schemaobject可选JSON Schema the annotation of each detected image region must follow.
document_annotation_formatobject可选○ UnsupportedStructured document annotation; OCR requires json_schema. Availability depends on the model.
Unsupported on glm-ocr; passing it returns 400.
▸ 展开子字段(2)
typestring可选Response format type of the annotation.
json_schemaobject可选JSON Schema the document annotation must follow.
document_annotation_promptstring可选○ UnsupportedInstruction for the document annotation, which says what to extract. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
Unsupported on glm-ocr; passing it returns 400.
▸ 更多参数(4)
image_limitinteger可选○ UnsupportedMaximum number of images to extract per document; null for no limit. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
Unsupported on glm-ocr; passing it returns 400.
image_min_sizeinteger可选○ UnsupportedMinimum height and width in pixels of images to extract; null for no minimum. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
Unsupported on glm-ocr; passing it returns 400.
include_blocksboolean可选○ UnsupportedWhether to return layout `blocks` for each page. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
Unsupported on glm-ocr; passing it returns 400.
confidence_scores_granularitystring可选○ UnsupportedLevel at which confidence scores are returned. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
Unsupported on glm-ocr; passing it returns 400.
Returns
200
Uses the Mistral OCR request and response shape at /model/v1/ocr only. model is required; document accepts document_url or image_url (HTTPS or base64 data URL), or `{type:"file", file_id:"<uploaded ID>"}` to read a File owned by the authenticated tenant. The file_id read limit is 24 MiB (25,165,824 bytes: the shared 96 MiB memory budget divided by four). Larger files return 413 with guidance to use HTTPS document_url (PDF limit: 50 MiB). PNG/JPEG remain limited to 10 MiB; the bytes determine the type. Missing and other-tenant files both return 404. pages is an array of zero-based page indices; for images, only `[0]` is supported when supplied. File read failures are not billed, and request logs retain only the file_id, never the file content. Optional features depend on the model; unsupported options return 400. Errors use problem+json; providerOptions.praxis is not supported here.
Platform errors (auth, rate limits, validation) and OCR errors use problem+json; other model call errors follow the endpoint's own format (OpenAI or Anthropic) — see error codes
Response
HTTP 200
OCR pages and usage
application/json
| Name | Type | Description |
|---|---|---|
| pages | array<object> | Result per processed page, in page order. |
| pages[].index | integer | Zero-based index of the page in the document. |
| pages[].markdown | string | Page content as markdown. |
| pages[].images | array<object> | Images found on the page. |
| pages[].dimensions | object | null | Size of the rendered page; null when unknown. |
| pages[].tables | array<object> | Tables extracted from the page when table_format is set. |
| pages[].hyperlinks | array<string> | Hyperlinks found on the page. |
| pages[].header | string | null | Page header text; null when none was extracted. |
| pages[].footer | string | null | Page footer text; null when none was extracted. |
| pages[].blocks | array<object> | null | Layout blocks of the page, in reading order, when include_blocks is true. |
| pages[].confidence_scores | object | null | Confidence scores of the page; null when not requested. |
| model | string | OCR model that processed the document. |
| usage_info | object | Usage of the request. |
| usage_info.pages_processed | integer | Number of pages that were processed. |
| usage_info.doc_size_bytes | integer | null | Size of the document in bytes; null when unknown. |
| document_annotation | string | null | Document annotation as a JSON string, when document_annotation_format was requested; null otherwise. |