What is a Flow?
Flows connect nodes together to form processing pipelines:- Linear execution chain: Steps run sequentially by default
- Type-safe data passing: TypeScript ensures outputs match expected inputs
- Stateful context: Each step can access outputs from previous steps
- Built-in metrics: Automatic cost and duration tracking
Flow Builder Pattern
Flows use a fluent API for declarative pipeline definition:Key Methods
| Method | Description |
|---|---|
createFlow() | Initialize a new flow |
.step(id, node) | Add a sequential processing step |
.conditional(id, fn) | Add conditional branching based on data |
.forEach(id, fn) | Process arrays in parallel |
.build() | Compile the flow into an executable |
Execution Patterns
Sequential Processing
Default pattern—each step runs after the previous completes:Conditional Routing
Route documents based on previous step output:Parallel Processing
Process arrays of documents in parallel:Flow Results
Every flow execution returns:Accessing Results
Flow Context
Each step has access to the flow context:Flow Composition
Reusing Flows
Flows can be defined once and reused:Nested Flows
Use flows inside forEach:Common Flow Patterns
Simple Extraction
OCR + Extraction
Multi-Document Bundle
Quality-Based Routing
Route based on document quality assessment:trigger with nested flows: