Model

Extract document text

Extract text from documents or images as per-page Markdown with images and page usage.

POST /model/v1/ocr● Supported

Official docs ↗

Request 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 supported

    Include extracted images as base64.

    glm-ocr accepts false only; true returns 400.

  • table_formatstring可选◐ Partially supported

    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 accepts markdown or null only; html returns 400.

  • extract_headerboolean可选○ Unsupported

    Whether 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可选○ Unsupported

    Whether 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可选○ Unsupported

    Structured 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.

      取值 textjson_objectjson_schema
    • json_schemaobject可选

      JSON Schema the annotation of each detected image region must follow.

  • document_annotation_formatobject可选○ Unsupported

    Structured 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.

      取值 textjson_objectjson_schema
    • json_schemaobject可选

      JSON Schema the document annotation must follow.

  • document_annotation_promptstring可选○ Unsupported

    Instruction 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可选○ Unsupported

      Maximum 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可选○ Unsupported

      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.

      Unsupported on glm-ocr; passing it returns 400.

    • include_blocksboolean可选○ Unsupported

      Whether 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可选○ Unsupported

      Level 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

NameTypeDescription
pagesarray<object>Result per processed page, in page order.
pages[].indexintegerZero-based index of the page in the document.
pages[].markdownstringPage content as markdown.
pages[].imagesarray<object>Images found on the page.
pages[].dimensionsobject | nullSize of the rendered page; null when unknown.
pages[].tablesarray<object>Tables extracted from the page when table_format is set.
pages[].hyperlinksarray<string>Hyperlinks found on the page.
pages[].headerstring | nullPage header text; null when none was extracted.
pages[].footerstring | nullPage footer text; null when none was extracted.
pages[].blocksarray<object> | nullLayout blocks of the page, in reading order, when include_blocks is true.
pages[].confidence_scoresobject | nullConfidence scores of the page; null when not requested.
modelstringOCR model that processed the document.
usage_infoobjectUsage of the request.
usage_info.pages_processedintegerNumber of pages that were processed.
usage_info.doc_size_bytesinteger | nullSize of the document in bytes; null when unknown.
document_annotationstring | nullDocument annotation as a JSON string, when document_annotation_format was requested; null otherwise.