文档识别
识别文档或图片中的文字,返回逐页 Markdown、提取的图片与页数用量。
/model/v1/ocr● 支持请求体
modelstring必填OCR model ID, for example glm-ocr.
已验证生效。
documentobject必填Choose document_url, image_url (HTTPS or data URL), or {type: file, file_id: string}.
支持 PDF data URL、image_url 和已上传文件的 file_id;远端 URL 需可下载。
▸ 展开子字段(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.
零起始页码,可选择多页并去重;越界页会报错。
include_image_base64boolean可选◐ 部分支持Include extracted images as base64.
glm-ocr 仅接受 false;true 返回 400。
table_formatstring可选◐ 部分支持Format 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 仅接受 markdown 或 null;html 返回 400。
extract_headerboolean可选○ 未支持Whether to extract page headers separately into `header`. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
glm-ocr 不支持,传入返回 400。
extract_footerboolean可选○ 未支持Whether to extract page footers separately into `footer`. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
glm-ocr 不支持,传入返回 400。
bbox_annotation_formatobject可选○ 未支持Structured image annotations; OCR requires json_schema. Availability depends on the model.
glm-ocr 不支持,传入返回 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可选○ 未支持Structured document annotation; OCR requires json_schema. Availability depends on the model.
glm-ocr 不支持,传入返回 400。
▸ 展开子字段(2)
typestring可选Response format type of the annotation.
json_schemaobject可选JSON Schema the document annotation must follow.
document_annotation_promptstring可选○ 未支持Instruction for the document annotation, which says what to extract. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
glm-ocr 不支持,传入返回 400。
▸ 更多参数(4)
image_limitinteger可选○ 未支持Maximum number of images to extract per document; null for no limit. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
glm-ocr 不支持,传入返回 400。
image_min_sizeinteger可选○ 未支持Minimum height and width in pixels of images to extract; null for no minimum. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
glm-ocr 不支持,传入返回 400。
include_blocksboolean可选○ 未支持Whether to return layout `blocks` for each page. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
glm-ocr 不支持,传入返回 400。
confidence_scores_granularitystring可选○ 未支持Level at which confidence scores are returned. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.
glm-ocr 不支持,传入返回 400。
返回
200
采用 Mistral OCR 请求与响应形状,仅提供 /model/v1/ocr。model 必填;document 接受 document_url 或 image_url(HTTPS 或 base64 data URL),也接受 `{type:"file", file_id:"<上传所得 ID>"}`,直接读取当前租户的 File。file_id 读取上限为 24 MiB(25,165,824 字节,共享 96 MiB 内存预算按四倍预留);超过此上限返回 413,并提示改用 HTTPS document_url(PDF 上限 50 MiB)。PNG/JPEG 仍限 10 MiB,按文件头识别类型;不存在或其他租户的文件统一返回 404。pages 是从 0 开始的页码数组;图片如指定 pages,只能为 `[0]`。文件读取失败不计费,请求日志仅记录 file_id,不保存文件原文。可选功能依模型而定,不支持的选项返回 400。错误为 problem+json;providerOptions.praxis 不适用于此端点。
鉴权、限流、参数校验等平台错误按 problem+json 返回;OCR 的错误也为 problem+json,其它模型调用的错误按该端点所属格式(OpenAI 或 Anthropic)返回,参见 错误码
响应
HTTP 200
OCR pages and usage
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| 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. |