Skip to main content
Use the document text extractor node to extract the texts from your documents.

Pre-requisites

Run the following command to enable watsonx Orchestrate Developer Edition to process documents:
BASH
Note: You need to configure a minimum allocation of 20GB RAM to your Docker engine during installation of watsonx Orchestrate Developer edition to support document processing features.

Configuring document processing in flows

In your agentic workflow, include a call to the docproc() method to process a document.

Supported arguments

string
required
Unique identifier for the node.
string
required
Specifies which information is extracted from the document upon processing; supported values are:
  • text_extraction: Extracts plain text from documents.
string
Display name for the node.
string
Description of the node.
DocProcOutputFormat
Controls the output schema of the results. The possible values are:
  • DocProcOutputFormat.docref (“docref”): This is the default value.
    • Returns a URL reference to the stored extraction result
    • Response type: TextExtractionResponse
    • Best for documents that contain large amount of text or complex structures where the expected output is large.
  • DocProcOutputFormat.object (“object”):
    • Returns extraction results as an inline JSON object.
    • Response type: TextExtractionObjectResponse
    • Best for small documents or when the output of this node needs to flow into another node.
    • When using this value, it is highly recommended to map all top-level output fields in TextExtractionObjectResponse into the input of downstream nodes or the flow output.
DataMap
Define input mappings using a structured collection of Assignment objects.
boolean
Controls whether the output includes additional fields as part of the document assembly. Set to true to include these fields.
list[DocProcKVPSchema]
The key-value pair schemas used for extraction.
boolean
Enable the handwritten feature by setting this to true.
string
The LLM model used for key-value pair extraction. If no value is provided, the default WDU model is used. The default model is currently watsonx/mistralai/mistral-small-3-1-24b-instruct-2503. The name of the model must match the list of models registered with your watsonx Orchestrate environment. To check the list of models, see List all LLMs.Compatible models must be able to process images as input and respond in JSON format. Examples include:
  • watsonx/mistralai/mistral-small-3-1-24b-instruct-2503
  • watsonx/mistralai/mistral-medium-2505
  • watsonx/meta-llama/llama-4-maverick-17b-128e-instruct-fp8
string
The schema name used for KVP extraction. If not set or None, uses the default schema.
bool
Enables text hints to assist with KVP extraction.
PageRange
Limits text extraction to a specific range of pages. When set, the node extracts text only from that page range. If not set, the node extracts all pages.Use PageRange(start=1, end=5) to extract text from pages 1 through 5.
list[string]
The list of content formats to include in the extraction output. Accepted values are text, markdown, and html. When not set, the default extraction format is used. Pass an empty list [] to skip text extraction entirely. This is useful when only KVP extraction is needed.
LanguageCode
The ISO-639 language code that specifies the document’s language for OCR processing. Use the LanguageCode enum to specify supported languages (e.g., LanguageCode.fr for French, LanguageCode.ja for Japanese). This parameter is essential for scanned PDFs and images containing non-Latin scripts, as it ensures the correct OCR engine is used to recognize characters accurately. Programmatic documents (PDF, .docx, .pptx) do not require this setting.

Using the docproc() method

The input to a docproc node uses the DocProcInput type from the ibm_watsonx_orchestrate.flow_builder.types module. You can optionally configure the kvp_schemas parameter to define key-value pair input schemas. For more information, see Semantic Key-Value Pair (KVP) Extraction. Example use of the docproc node in an agentic workflow:
Python
After the node runs, you receive a URL pointing to a file that contains the extracted text. If you configure key-value pair (KVP) extraction, the file also includes the extracted KVPs.

Using the language parameter

For scanned PDFs and images containing non-Latin scripts, specify the document’s language to ensure accurate OCR processing:
Python

Text extraction with page range

Use the page_range parameter to limit extraction to a specific set of pages. For large documents where only a portion of the content is relevant, this parameter reduces processing time and output size. Import PageRange from ibm_watsonx_orchestrate.flow_builder.types and pass it to docproc() as shown in the following example:
Example

Semantic Key-Value Pair (KVP) Extraction

Use the kvp_schemas parameter in the text extraction task to extract semantic key-value pairs from input documents. For more information about configuring text extractors in watsonx Orchestrate, see Semantic key-value pair extraction: When to use and limitations. You can define this parameter in two places:
  • Node specification: Set kvp_schemas in the node configuration. The node supports semantic KVP extraction in the following cases:
    • If you define kvp_schemas in the input, the node uses those schemas. If you pass an empty array, it falls back to default schemas.
    • If you don’t define kvp_schemas in the input but include them in the node specification, the node uses the specification-defined schemas. Again, if the array is empty, it defaults to the built-in schemas.
    The kvp_schemas is configured as a JSON object. The following example shows how to define kvp_schemas in a node configuration.
    Python
  • Runtime input: Set kvp_schemas in the input payload. The following example shows how to define a kvp_schemas in the input payload.
    Python
For both the node specification and runtime input, the default value of kvp_schemas is null. If you define the parameter in both places, the runtime input takes precedence and overrides the node specification. To use predefined extraction schemas, pass an empty array (kvp_schemas: []). Use kvp_force_schema_name to specify the schema name for KVP extraction. Use kvp_enable_text_hints to enable or disable text hints during extraction. Configure both settings inside the docproc() node.
Python

Document processing with output format

See the following examples to learn how to use custom output formats with document processing:
Python
Python

KVP schema with table fields

Use the "type": "array" field type with a "columns" definition to extract tabular data — such as invoice line items — from a KVP schema. The extractor returns an array of row objects, one per table row.
Python