Mindket

JSON answers in a fixed format with an auto-fix retry

Newversion 1 · updated

Overview

An n8n workflow that asks an OpenAI model a question and holds the answer to a JSON shape you define. A reply that does not fit goes to a second model call, which repairs it once.

JSON answers in a fixed format with an auto-fix retry is an n8n workflow in the Developer category, listed by Mindket. It is free. This is version 1, last updated on . Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

At a glance

Runs in
  • n8n Cloud: import the file into a new workflow there
  • Your own n8n server: the same file and steps
  • Other workflows: copy LLM Chain and its two parsers into a workflow that has its own trigger and prompt
  • Another chat model: swap the two OpenAI model nodes for a different chat model node

Platform

Connects 1 app

How it works

Trigger

Manual run

It starts when you press Execute workflow, and there is no form:

  • No input from you: the question is set inside the workflow

Actions

  1. A step sets the question: the five largest US states by area, each with its three largest cities and their populations
  2. The chain sends it to an OpenAI model with the instructions of the schema
  3. The Structured Output Parser checks the reply against the schema
  4. A reply that does not fit goes to a second OpenAI call with the error, which writes one new attempt
  5. The parsed answer leaves the chain, as one item or as a list in a data field

Result

The model’s answer as data in the shape of your schema, repaired once if it first came back wrong

Integrations

What you need before you start.

OpenAI

Language model

Answers the question and, in a second node, repairs a reply that does not fit the schema.

NeedsOpenAI API key

Workflow check

Checked by Mindket on 13 Nov 2026

Steps
3 steps, starting by hand
AI
1 step calls an AI model: LLM Chain
Sign-ins
Signs in to: OpenAI
API keys
No API key is left in the file
Step types
Mindket’s checker reads all 3 of its step types

Read from the workflow’s file, not from a run.

About

What it is

This n8n workflow shows how to make a language model answer in a fixed JSON shape. You press a button, and a prompt asks OpenAI for the five largest US states by area, each with its three largest cities and their populations. A Structured Output Parser holds the answer to a schema. An Auto-fixing Output Parser wraps it and sends a bad reply to a second model call, which repairs it once. Eleven nodes do the work, four of them sticky notes.

Who it suits

Builders of n8n workflows who need a model’s answer as data that later nodes can read, such as a row to store or a field to branch on. Skip it if you want free text. It runs by hand from the editor, so it is a pattern to copy, not a service.

Who uses it, and how
IndustryWho uses itHow they use itExample
SoftwareWorkflow buildersMake a model return fields that a later node can useA builder asks for a ticket’s category and urgency as two fields.
OperationsOperations analystsTurn free text into rowsAn analyst pulls the supplier, amount and date out of an email.
ResearchData teamsCollect facts from a passage in one fixed layoutA team lists the people and companies an article names.
MarketingContent teamsGet product copy back in labelled partsA marketer asks for a headline, a subtitle and three bullets.

You need a little n8n: import a file, add an OpenAI credential and run it.

Where to use it

Any n8n that can reach OpenAI will run it. The reply appears in the output of the LLM Chain node.

  • n8n Cloud: import the file into a new workflow there
  • Your own n8n server: the same file and steps
  • Other workflows: copy LLM Chain and its two parsers into a workflow that has its own trigger and prompt
  • Another chat model: swap the two OpenAI model nodes for a different chat model node

Setup

Download saves a zip with workflow.json and Mindket’s setup notes in your downloads folder. Setup is one credential, used in two nodes, and a model choice in each.

What you need first
NeedDetail
n8nOn n8n Cloud or on a server of your own
OpenAIAn API key
  1. In n8n, create a workflow, open its menu, choose Import from File and pick workflow.json.
  2. Add an OpenAI credential with your key and select it in OpenAI Chat Model and OpenAI Chat Model1.
  3. Pick a model in each of those two nodes. The default, gpt-5-mini, is due to shut down on 11 December 2026.
  4. Press Execute workflow, then open LLM Chain to read the answer.

How to use it

Change the question in Prompt and the schema in Structured Output Parser, then run it again. The schema tells the model which fields to return, and the parser rejects anything else. A rejected reply goes to OpenAI Chat Model1 with the error, and that model writes one new attempt.

What to change for a different result
To changeWhere
The questionThe input value in Prompt
The shape of the answerThe jsonSchema in Structured Output Parser
The repair instructionsThe prompt option of Auto-fixing Output Parser, which must keep {error}
The modelsOpenAI Chat Model for the answer and OpenAI Chat Model1 for the repair

Example

A builder keeps the question as it ships and reads what comes back.

The model answers in JSON. If the parser accepts the reply, LLM Chain outputs it: a single object comes out as the item, and a list comes out as an item whose data field holds the list. If not, the repair call tries once more. Check the figures against a source, since the parser checks shape and not truth.

For newcomers and experts

If you are new. n8n draws a workflow as boxes joined by lines, and each box, a node, does one job. A model’s reply is plain text, so a later node cannot count on its layout. A parser reads the reply against a schema and hands on data in the shape you asked for. The two models hang under the chain instead of sitting in the line.

For experts. LLM Chain is the Basic LLM Chain with its output parser switched on. Structured Output Parser takes the JSON schema. In n8n’s current code it accepts one object or a list of that object. Auto-fixing Output Parser wraps it. On a failure it sends the instructions, the bad reply and the error to its own model.

Where to look closer
NodeWhat it doesWhat to know
PromptSets the input fieldThe chain reads its prompt from input
LLM ChainSends the prompt and applies the parserAn object comes out as the item, a list as a data field
Structured Output ParserHolds the schemaname and population are bare words, so any value passes
Auto-fixing Output ParserRepairs a bad reply onceA second failure stops the run with an error
OpenAI Chat Model1Writes the repairIt can be a different model from the first

Good to know

The workflow runs by hand and leans on a default model that is going away.

  • Models: the two model nodes set no model, so each takes the node’s default, gpt-5-mini in n8n’s repository on 12 November 2026. OpenAI’s deprecations page, read that day, lists gpt-5-mini for shutdown on 11 December 2026, with gpt-5.6-terra as the replacement. Both nodes also set a temperature of 0, so clear it if OpenAI refuses it for the model you pick
  • Schema: it describes one state with a list of cities, while the question asks for five states. In n8n’s current code a list of five passes, so the run works, but write the shape you mean
  • Loose fields: name and population are bare words, not {"type": "string"}, so any value passes. Write each as an object with a type to enforce it
  • One repair: if the second reply still fails the schema, the run stops with an error
  • Billing: each run makes at least one model call, and a repair makes a second
  • Trigger: manual, so nothing runs until you press the button
  • Your data: the question and the reply go to OpenAI
  • Credentials: the JSON holds none

README and files

README

JSON answers in a fixed format with an auto-fix retry

An n8n workflow that asks an OpenAI model a question and holds the answer to a JSON shape you define. A Structured Output
Parser keeps the shape. An Auto-fixing Output Parser sends a reply that does not fit to a second model call, which repairs it.

What is inside

  • workflow.json: the workflow as n8n exports it, 11 nodes, four of them sticky notes. It holds no credential. The notes
    label the four parts of the canvas: the first model, the auto-fixing parser, the model that repairs and the schema.
  • README.md: these notes.

What we changed from the original copy

  • Both model nodes were linked to a credential in their author's n8n. The links are gone, so select your own.
  • The export's instance id and version id are gone.
  • Nothing else. The file has no Code node, and its expressions needed no repair.

Before you start

  • An n8n instance, on n8n Cloud or your own server.
  • An OpenAI API key.

Set it up

  1. In n8n, create a workflow, open its menu and choose Import from File. Pick workflow.json.
  2. Add an OpenAI credential with your key. Select it in OpenAI Chat Model and OpenAI Chat Model1.
  3. Pick a model in each of those two nodes. The default, gpt-5-mini, is due to shut down on 11 December 2026.
  4. Press Execute workflow and open LLM Chain to read the answer.
  5. Change the question in Prompt, and the schema in Structured Output Parser to match it.

How a run goes

  1. When clicking "Execute Workflow" starts the run by hand.
  2. Prompt sets one field, input, to a question: the 5 largest US states by area, each with its 3 largest cities and
    their population.
  3. LLM Chain reads input as its prompt and sends it to OpenAI Chat Model, which has a temperature of 0.
  4. The chain is told to answer in the shape held by Structured Output Parser. Auto-fixing Output Parser wraps that parser.
  5. A reply that does not parse, or does not fit the schema, goes to OpenAI Chat Model1. It receives the instructions, the bad
    reply and the error in n8n's default repair prompt, and writes one new attempt.
  6. A reply that fits leaves LLM Chain. In n8n's current code a single object comes out as the item itself, and a list of
    objects comes out as an item whose data field holds the list.

Change the look

  • The question: the input value in Prompt.
  • The shape: the jsonSchema in Structured Output Parser.
  • The repair instructions: add a custom prompt in the options of Auto-fixing Output Parser. It must keep the {error} placeholder.
  • The models: OpenAI Chat Model for the answer and OpenAI Chat Model1 for the repair. They can differ.

Good to know

  • Models: the two model nodes set no model, so they take the node's own default, gpt-5-mini in n8n's repository on
    12 November 2026. OpenAI's deprecations page, read that day, gives 11 December 2026 as the shutdown of gpt-5-mini, with
    gpt-5.6-terra as the replacement. Pick a model in each node. Both nodes also set a temperature of 0, so clear it if
    OpenAI refuses it for the model you choose.
  • The schema describes one state with a list of cities, while the question asks for five states. In n8n's current code the
    parser accepts one object or a list of them, so a list of five passes.
  • name and population are written as bare words, as in "name": "string", not as {"type": "string"}. n8n's converter
    lets such a property take any value, so a population written as text also passes. Write each as an object with a type to
    enforce it.
  • The repair is a single attempt. If the second reply still fails the schema, the run stops with an error.
  • Billing: each run makes at least one model call, and a reply that needs repair makes a second.
  • Your data: the question and the model's reply go to OpenAI.
  • The trigger is manual, so nothing runs until you press the button.
Files
NOTICE.md  602 B
README.md  4 KB
workflow.json  5 KB

3 files, 10 KB, downloaded as a zip.

What’s new

  • Version 1 · 2026-11-12

Reviews

No ratings yet

Write a review

No reviews yet.

More from Mindket

See all from Mindket

upscaler

uwg · Kit

Holds a set of image upscaling models gathered from the OpenModelDB community, for people who want to enlarge low-resolution pictures with AI on their own comp…

New

Pixel Art XL

nerijs · Kit

A pixel art style add-on for Stable Diffusion XL that turns text prompts into pixel-style images, with an optional LCM LoRA for faster runs. For game makers, d…

New

VibeVoice-1.5B

microsoft · Kit

Turns written conversations into spoken audio with up to four speakers and about 90 minutes of speech, an open Microsoft text-to-speech model for research on p…

New

Similar in Developer

See all in Developer

voicetut-egyptian-tashkeel

masterofaudio2077 · Kit

Reads Egyptian Arabic text aloud and follows the short vowel marks you write into it. A fine-tune of VoiceTut-TTS that keeps its 19 built-in voices and voice c…

New

Runs Meta's Llama 3.1 8B Instruct chat model in 4-bit AWQ form, so it fits on a GPU with about 4 GiB of free memory for the weights. For developers who want a…

New

Ru-Jev

besktech · Kit

Scores a Russian-first decision from a context and a list of options, giving a probability for yes/no, choice or rating questions. Runs on a plain CPU, for tea…

New