LM-Kit OneDocs2026.8.10lm-kit.com
AI Extraction

Document to Markdown

Converts a document or image to Markdown.#

POST/lmkit/v1/document-to-markdown

Transcribes documents and images into structured Markdown using one of three strategies: 'Hybrid' (default) routes each page to the fastest suitable path (embedded text layer or vision-language OCR) based on whether the page has extractable text and whether it contains embedded images; 'TextExtraction' reads only the embedded text layer and can also OCR image inputs through the server's default OCR engine when 'enable_ocr' is true; 'VlmOcr' rasterizes every page and transcribes it with a vision-language model. Multi-page documents are processed page by page and the results are concatenated. Supported document formats: PDF, DOCX, PPTX, XLSX, EML, MBOX, HTML, TXT. Supported image formats: PNG, JPEG, TIFF, BMP, GIF, WEBP, PSD, PIC, PNM, HDR, TGA. If processing exceeds the configured timeout, returns 202 Accepted with a job_id. Poll GET /lmkit/v1/jobs/ for status and results.

Request body

application/json ·

PropertyTypeDescription
modelstring

The identifier of the vision-language model used when the conversion strategy requires one (Hybrid or VlmOcr). Ignored for the TextExtraction strategy. If not provided, the server's default vision OCR model is used.

inputrequiredstring

The input document or image to convert. When input_format is 'Base64EncodedFile', provide a base64-encoded file payload. Supported document formats: PDF, DOCX, PPTX, XLSX, EML, MBOX, HTML, TXT. Supported image formats: PNG, JPEG, TIFF, BMP, GIF, WEBP, PSD, PIC, PNM, HDR, TGA. When 'FileIdentifier', provide the file ID previously returned by the api/v1/files/upload endpoint.

input_format

How the input is provided. Accepted values: 'Base64EncodedFile' or 'FileIdentifier'. 'FileIdentifier' references a file previously uploaded via api/v1/files/upload. Defaults to 'Base64EncodedFile'.

strategy

The conversion strategy. 'Hybrid' (default) inspects each page individually: pages with a clean text layer stay on the fast text path, while pages without extractable text or containing embedded images are routed to the vision-language model. 'TextExtraction' reads only the embedded text layer (fastest, no model required); when 'enable_ocr' is true, image inputs are routed through the server's default OCR engine. 'VlmOcr' rasterizes every page and transcribes it with the vision-language model (slowest, most robust).

enable_ocrboolean

When true, the server's default OCR engine is used to extract text from image inputs under the 'TextExtraction' strategy. Requires an OCR provider to be configured on the server. Ignored by the 'Hybrid' and 'VlmOcr' strategies, which always use the vision-language model. Defaults to true.

strip_image_markupboolean

When true, Markdown image references (e.g. ![alt](path.png)) are removed from the output, leaving only textual content. Applies to vision-language output. Defaults to true.

max_completion_tokensobject (int32)

The maximum number of tokens the vision-language model is allowed to emit per page. On average, one token corresponds to approximately 4 characters of text. Set to -1 to disable the limit. Applies to the 'Hybrid' and 'VlmOcr' strategies only. Defaults to 3072.

pagesstring

An optional page range to process (e.g. "1-3", "1,3,5", "2-"). When empty or not specified, all pages are processed. Page numbers are 1-based.

Responses

StatusTypeDescription
200

OK

202

Accepted

400

Bad Request

404

Not Found

500application/json

Internal Server Error

curl -X POST "$LMKIT_ONE_URL/lmkit/v1/document-to-markdown" \
  -H "Authorization: Bearer $LMKIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "",
  "input": "",
  "input_format": "Base64EncodedFile",
  "strategy": 2,
  "enable_ocr": true
}'