Skip to content
AI Agents

LLM Chain with Structured Output Parser and Auto-Fixing

11 nodes 49 4 Manual trigger
Download

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. 1.Manual Execute Workflow trigger starts the run.
  2. 2.A Set node stores the fixed question in the input field.
  3. 3.The prompt flows to an LLM Chain powered by OpenAI Chat Model at temperature 0.
  4. 4.A Structured Output Parser defines a JSON schema of state plus an array of cities with numeric population.
  5. 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

  1. Execute the workflow manually from the n8n editor.
  2. Verify the result matches the defined JSON schema.
  3. 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

Manual Trigger Set LLM Chain Output Parser OpenAI

Details

Trigger Manual trigger
Nodes 11
Apps 5
Views 49
Downloads 4

How to Use

  1. 1.Click "Download Template"
  2. 2.Open your n8n dashboard
  3. 3.Go to Workflows > Import from File
  4. 4.Select downloaded file and configure credentials

Nodes Used (11)

/

When clicking "Execute Workflow"

Manual Trigger

#1

Prompt

Set

#2

LLM Chain

LLM Chain

#3

Structured Output Parser

Output Parser Structured

#4

Auto-fixing Output Parser

Output Parser Autofixing

#5

Sticky Note

Sticky Note

#6

Sticky Note1

Sticky Note

#7

Sticky Note2

Sticky Note

#8

Sticky Note3

Sticky Note

#9

OpenAI Chat Model

OpenAI

#10

OpenAI Chat Model1

OpenAI

#11

Source and license

Sticky Note

#12
Stay in the loop

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

Be first to discover what is new

Your name, your email, and one confirmation.

Email confirmation · Unsubscribe anytime