When to use
Use fan-out extraction when your app needs to process documents that vary significantly in structure and content. A single extraction prompt cannot handle the differences between an invoice, a bill of lading, and a fuel receipt β each has different fields, layouts, and validation rules. This pattern is the right choice when:- You receive mixed document types in a single pipeline (email attachments, bulk uploads)
- Each document type has a distinct schema with specialized fields
- You need high extraction accuracy per type rather than a generic best-effort pass
- The number of document types may grow over time without rearchitecting the workflow
Architecture
The pattern follows two phases: classification, then type-specific extraction.This pattern uses the document nodes because they accept files directly. The TEXT_UNDERSTANDING and TEXT_EXTRACTION nodes work on text input only β to use them here, you would first need to convert the file to text with the Extract Data from File node.
Phase 1: Classification
A DOCUMENT_UNDERSTANDING node receives the document file and classifies it into one of the known types. The classification instructions constrain the output to an enumerated list, so the Condition node can route deterministically.Phase 2: Type-specific extraction
Each branch contains a DOCUMENT_EXTRACTION node configured with:- Instructions tailored to that document type, telling the model which fields to look for
- A response schema defining the exact JSON structure expected for that type
- An Extraction Method suited to the document format (text-heavy PDFs vs. scanned images)
Implementation
Step 1: Configure the classification node
Add a DOCUMENT_UNDERSTANDING node and configure it to classify the document type. Example classification instructions:Step 2: Add the Condition node
Add a Condition node after the classification node. Configure branches based on thedocument_type value:
Step 3: Configure type-specific extraction nodes
Each branch gets its own DOCUMENT_EXTRACTION node with instructions and a schema optimized for that document type. The node works directly on the uploaded file.- BOL (Bill of Lading)
- Invoice
- Rate confirmation
Prompt:Response schema:
Configuration reference
If you need the raw text rather than schema-based extraction, use the Extract Data from File node instead β it supports PDF, DOCX, XLSX, PPTX, HTML, CSV, Markdown, AsciiDoc, and image formats (JPG, PNG, TIFF, BMP, WEBP), processing images directly through OCR. Its text output can then feed TEXT_UNDERSTANDING or TEXT_EXTRACTION nodes.
Scaling to many document types
This pattern scales well because adding a new document type requires only:- Adding the new type to the classifierβs enumerated list
- Adding a new branch in the Condition node
- Adding a new DOCUMENT_EXTRACTION node with the type-specific instructions and schema
Variations
Parallel extraction
Instead of classifying first, run extraction for all document types simultaneously and pick the result with the highest confidence. This trades compute cost for lower latency and avoids classification errors.Parallel extraction works best when you have a small number of document types (under 5). Beyond that, the cost of running every extractor on every document becomes impractical.
Hierarchical classification
For large document sets, classify in two stages: first into a broad category (financial, shipping, legal), then into a specific type within that category. This reduces the number of options the classifier evaluates at each stage.Confidence fallback
Add a confidence threshold to the classification step. If the classifier returns a confidence below the threshold, route the document to a manual classification queue instead of risking an incorrect extraction.Related resources
Patterns overview
All available AI patterns and how to combine them
AI node types
Reference for DOCUMENT_UNDERSTANDING, DOCUMENT_EXTRACTION, and other node types
Extract Data from File
Configuration guide for the Extract Data from File node
AI comparison and reconciliation
Compare extracted data against system-of-record values

