Extract text from document
Documentdocument.extract_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 modality | Document file — a public http(s) URL, or a file stored on the platform |
| Output modality | Text (markdown or JSON) |
| Supported formats | PDF, DOCX, XLSX, PPTX, HTML, PNG, JPEG, TIFF |
| Max input size | 100 MB |
The document is named ONE of two ways — set exactly one:
| Input | What it is |
|---|---|
document_url | A public http(s) URL, or a ${steps.<id>.outputRef} binding (which resolves to a gs:// object we hold) |
file_id | The 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 a404, never a read. What actually reaches the extraction worker is a short-lived signedhttpsURL 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
| Param | Required | Description |
|---|---|---|
ocr | no | OCR mode — auto (try text layer first), force (always OCR), off (text layer only). Default: auto |
output_format | no | Output 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 PDFdocument.render_slides— render markdown as a slide deck
Examples
PDF with auto-OCR → markdown
{
"ocr": "auto",
"output_format": "markdown"
}