infery
← All tools

Extract text from document

Document

document.extract_text

in: documentout: text

Parse PDF/DOCX/HTML/etc. to markdown or JSON, with optional OCR.

Pricing

Price
1.25 cr / request

Prices in credits (1 credit = $0.01).

Extract Text from Document

Parse PDF, DOCX, HTML, and other document formats into structured markdown or JSON, with optional OCR for scanned pages.

When to use

  • Extract content from PDFs (reports, contracts, invoices) for downstream text processing.
  • OCR scanned documents — force OCR on image-only PDFs where no selectable text layer exists.
  • Normalize to markdown for ingestion into RAG pipelines or LLM context windows.

Inputs & outputs

Input modalityDocument file — a public http(s) URL, or a file stored on the platform
Output modalityText (markdown or JSON)
Supported formatsPDF, DOCX, XLSX, PPTX, HTML, PNG, JPEG, TIFF
Max input size100 MB

The document is named ONE of two ways — set exactly one:

InputWhat it is
document_urlA public http(s) URL, or a ${steps.<id>.outputRef} binding (which resolves to a gs:// object we hold)
file_idThe id of a stored file — what POST /v1/files returned, or ${steps.<id>.output.file_id}

Both spellings of a file we hold are workspace-scoped. A gs:// object or a file id belonging to another workspace is a 404, never a read. What actually reaches the extraction worker is a short-lived signed https URL for that one object, minted per call and never persisted.

The document type. For a stored file it comes from the file's own recorded type (sniffed from its bytes at upload), so nothing has to be declared. For an external URL it is read from the extension, and a URL that ends in none — no .pdf, .docx, .pptx, .xlsx, .html, .png, .jpg, .tif — is refused with 400 unsupported_mime. Upload it and pass file_id instead.

Parameters

ParamRequiredDescription
ocrnoOCR mode — auto (try text layer first), force (always OCR), off (text layer only). Default: auto
output_formatnoOutput format — markdown or json. Default: markdown

Examples

PDF with auto-OCR → markdown

{
  "type": "document.extract_text",
  "input": { "document_url": "https://example.com/docs/report.pdf" },
  "params": { "ocr": "auto", "output_format": "markdown" }
}

Force OCR on scanned invoice → JSON

{
  "type": "document.extract_text",
  "input": { "document_url": "https://example.com/docs/scanned_invoice.pdf" },
  "params": { "ocr": "force", "output_format": "json" }
}

A file you uploaded

POST /v1/files returns a file_id; pass it directly. No extension is needed — the stored type is used.

{
  "type": "document.extract_text",
  "input": { "file_id": "file_abc123" },
  "params": { "ocr": "auto", "output_format": "markdown" }
}

A document a previous step produced

{
  "type": "document.extract_text",
  "input": { "document_url": "${steps.render.outputRef}" },
  "params": { "ocr": "auto", "output_format": "markdown" }
}

Pricing

Billed per page processed. OCR pages are billed at a higher rate than text-layer extraction. See pricing dashboard for current rates.

Related capabilities

  • document.convert_format — convert the extracted markdown to HTML, DOCX, or PDF
  • document.render_slides — render markdown as a slide deck

Examples

PDF with auto-OCR → markdown

{
  "ocr": "auto",
  "output_format": "markdown"
}