For-each node

The For-each node maps a language model over an array of items: every
item becomes one model call (the item as the prompt, your instructions as
the system prompt), and the results are collected back into an array of { item, output } entries — in the same order as the input.
Use it to apply the same analysis, classification or transformation to a list — for example, score every row of a generated table, translate every line of a report, or summarize each search result — without writing a loop by hand.
Handles
| Handle | Purpose |
|---|---|
Items | The array to iterate over (a table, list or JSON array) |
Results | The collected [{ item, output }] array |
Configuration
- Model — the language model that runs once per item.
- Instructions — the system prompt, applied to every item (supports
{…}templates). Describe what to do with each item and what to return. - Items path — a dot-path into the run context pointing at the array to
iterate over (e.g.
outputs.<node-id>.rows). Leave empty to use the incoming payload when it is an array.
Where the items come from
The array is resolved in this order:
- If an Items path is set, read that path from the run context.
- Otherwise use the incoming payload, when it is an array.
Non-string items are serialized to JSON before being passed as the prompt, so a table row or a nested object becomes a readable text prompt automatically. If no items resolve, the run fails fast with a clear message.
Example — score every lead
A Table Generation node produces { sheets: [...] }. A For-each node reads
the rows and scores each one:
items: payload.rows (or outputs.<table-node>.sheets[0].rows)
model: openai/gpt-4.1-mini
instructions: "Rate each lead's quality from 1 (cold) to 5 (hot).
Reply with just the number." The Results handle emits:
[
{ "item": "{"name":"ACME"}", "output": "5" },
{ "item": "{"name":"Globex"}", "output": "3" }
] Wire that into a Table Generation node or an Agent to turn the raw scores into a finished report.
Notes
- One durable step — the items run in order, not in parallel, so re-runs are deterministic and each call is billed separately.
- If one item’s call fails, the batch stops and reports that error.
- The card shows the model and the items source at a glance.
Related
- Table Generation — a common source of the array.
- Agent — the single-item equivalent of this node.
- Router — branch once, rather than iterate.