LLM Chain with Structured Output Parser and Auto-Fixing
Loading workflow…
Workflow Description
A manually triggered workflow that asks an OpenAI Chat model (temperature 0) to return the 5 largest US states by area with their 3 largest cities and populations, and enforces a defined JSON schema via a Structured Output Parser wrapped in an Auto-fixing Output Parser backed by a second OpenAI model that repairs invalid outputs.
How it works
- 1.Manual Execute Workflow trigger starts the run.
- 2.A Set node stores the fixed question in the input field.
- 3.The prompt flows to an LLM Chain powered by OpenAI Chat Model at temperature 0.
- 4.A Structured Output Parser defines a JSON schema of state plus an array of cities with numeric population.
- 5.An Auto-fixing Output Parser wraps that schema and uses a second OpenAI model to repair non-conforming outputs.
Use cases
- Generating schema-valid geographic reference data for downstream processing.
- Demonstrating reliable structured LLM output with automatic validation and repair.
Requirements
- An n8n instance with the LangChain nodes available.
- Valid OpenAI API credentials attached to both Chat Model nodes.
- No user configuration needed; the prompt text is hardcoded in the Set node.
Setup and testing in n8n
- Execute the workflow manually from the n8n editor.
- Verify the result matches the defined JSON schema.
- Temporarily break the schema to observe the auto-fixing parser behavior.
Service Value
Ideal as a smart automation service combining integrations and AI to produce ready-to-use results.
Apps Used
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (11)
When clicking "Execute Workflow"
Manual Trigger
Prompt
Set
LLM Chain
LLM Chain
Structured Output Parser
Output Parser Structured
Auto-fixing Output Parser
Output Parser Autofixing
Sticky Note
Sticky Note
Sticky Note1
Sticky Note
Sticky Note2
Sticky Note
Sticky Note3
Sticky Note
OpenAI Chat Model
OpenAI
OpenAI Chat Model1
OpenAI
Source and license
Sticky Note
Fresh workflows, straight to your inbox
Get newly published DROPIDEA workflows, a clear overview of what they do, and a link to explore them.
- New workflows
- Clear overviews
- Setup guides