Iteration¶
The Iteration node processes arrays by running the same workflow steps on each element sequentially or in parallel. Use it for batch processing tasks that would otherwise hit limits or be inefficient as single operations.

How Iteration Works¶
The node takes an array input and creates a sub-workflow that runs once for each array element. During each iteration, the current item and its index are available as variables that internal nodes can reference.
Core Components:
- Input Variables - Array data from upstream nodes
- Internal Workflow - The processing steps to perform on each element
- Output Variables - Collected results from all iterations (also an array)
Configuration¶
Array Input¶
Connect an array variable from upstream nodes such as Parameter Extractor, Code nodes, Knowledge Retrieval, or HTTP Request responses.
Built-in Variables¶
Each iteration provides access to:
- items[object] - The current array element being processed
- index[number] - The current iteration index (starting from 0)
Processing Mode¶
Sequential Mode:
**Sequential Processing** - Items processed one after another in order
**Streaming Support** - Results can be output progressively using Answer nodes
**Resource Management** - Lower memory usage, predictable execution order
**Best For** - When order matters or when using streaming output
Parallel Mode:
**Concurrent Processing** - Up to 10 items processed simultaneously
**Improved Performance** - Faster execution for independent operations
**Batch Processing** - Handles large arrays efficiently
**Best For** - Independent operations where order doesn't matter


Error Handling¶
Configure how to handle processing failures for individual array elements:
Terminate - Stop processing when any error occurs and return the error message
Continue on Error - Skip failed items and continue processing, outputting null for failed elements
Remove Failed Results - Skip failed items and return only successful results
Input-output correspondence examples:
- Input: [1, 2, 3]
- Output with Continue on Error: [result-1, null, result-3]
- Output with Remove Failed: [result-1, result-3]
Long Article Generation Example¶
Generate lengthy content by processing chapter outlines individually:

Workflow Steps:
- Start Node - User provides story title and outline
- LLM Node - Generate detailed chapter breakdown
- Parameter Extractor - Convert chapter list to structured array
- Iteration Node - Process each chapter with internal LLM
- Answer Node - Stream chapter content as it's generated



Info:
Parameter extraction effectiveness depends on model capabilities and instruction quality. Use stronger models and provide examples in instructions to improve results.
Output Processing¶
Iteration nodes output arrays that often need conversion for final use:
Convert Array to Text¶
Using Code Node:
```python
def main(articleSections: list):
return {
"result": "\n".join(articleSections)
}
```
<img src="https://assets-docs.flexai.com.tr/flexai-enterprise-mintlify/en/guides/workflow/node/8be2372b00a802e981efe6f0ceff815b.png" alt="Code node conversion" />
Using Template Node:
```jinja
{{ articleSections | join("\n") }}
```
<img src="https://assets-docs.flexai.com.tr/flexai-enterprise-mintlify/en/guides/workflow/node/8c0bcc5de453dea2776d2755449bd971.png" alt="Template node conversion" />