n8n tutorial - Lesson 22: AI Image Generation in n8n with gpt-image-1
Hi everyone, in this session of our n8n workflow automation tutorial series, we cover how to fix broken image generation after OpenAI killed DALL-E, migrate to gpt-image-1, and extend the Content Factory with a YouTube metadata child workflow — all real steps from an actual n8n image generation AI build.
How to do:
Step 1 — Understand Why DALL-E Stopped Working
Before touching any node, confirm the root cause so you fix the right thing.- OpenAI permanently shut down DALL-E 2 and DALL-E 3 on 12 May 2026 (announced 14 November 2025). Any call to
model: "dall-e-3"returns error codemodel_not_foundwith the message "The model 'dall-e-3' does not exist" — there is no grace period. - The original plan from the previous session was to swap the OpenAI node for an HTTP Request node and simply remove
response_format. That partial fix is not enough because the model itself no longer exists. - Web-search to confirm the shutdown date before making any code change — never rely solely on AI knowledge when the situation is time-sensitive.
Note — This is a recurring lesson in production automation: when an AI assistant's training data is older than the current date, always run a quick search to verify before acting on its suggestion.
Step 2 — Migrate the Image Generation Node to gpt-image-1
Replace the dead DALL-E call with gpt-image-1 and update the request body to match the new API contract.- Open your T6-Content-Child-Blog workflow and locate the node that previously called DALL-E (either an OpenAI node or an HTTP Request node).
- In the HTTP Request node, set the Body to:
model:gpt-image-1prompt: your prompt expressionsize:1024x1024n:1
- Remove any
response_formatfield from the body — gpt-image-1 does not accept it and will error if it is present.
Tip — The endpoint URL stays the same (https://api.openai.com/v1/images/generations). Only the model name and body shape change, so keep your existing Authorization header and credentials untouched.
Step 3 — Handle the Base64 Response (Replace the Download Image Node)
gpt-image-1 returns a Base64 string, not a URL — the old Download Image node is now useless and must be replaced.- Understand the critical difference:
- DALL-E 3 returned:
data[0].url— a public URL you could GET directly. - gpt-image-1 returns:
data[0].b64_json— a raw Base64 string.
- DALL-E 3 returned:
- Delete (or disable) the Download Image node that previously performed a GET request on the image URL.
- Add a Code node named Base64 to Binary immediately after the HTTP Request node.
- Inside the Code node, write logic to:
- Read
$json.data[0].b64_jsonfrom the previous node's output. - Convert it to a binary buffer.
- Return it as a binary field named
dataso downstream nodes (e.g., Google Drive upload) can consume it.
- Read
- Connect the Code node output to your Google Drive upload node and confirm the binary field name matches what the Drive node expects.
Tip — After uploading, set the file permission to Anyone with the link / Reader (Make Public) in Google Drive. Without this, the thumbnail embed in your blog HTML (<img src="https://drive.google.com/thumbnail?id={id}&sz=w1024">) will return a 403 for public readers.
Step 4 — Fix the Draft Post URL and Post ID Fields
Verify the actual field names returned by the Blogger POST Draft node — two fields from the previous session were guessed incorrectly.- Run the Create Draft node against a real Blogger API call and inspect the raw output JSON.
- Confirm field mappings:
postId→ use{{ $json.id }}(top-level field — this guess was correct).blogId→ use{{ $json.blog.id }}.blogUrl→ do not use{{ $json.url }}for a draft. For a DRAFT post,urlonly returns the blog homepage, not a permalink.
- For the edit link, construct it manually:
https://www.blogger.com/blog/post/edit/{{ $json.blog.id }}/{{ $json.id }}
Note — A published post would populate url with the real permalink. Because this workflow saves drafts, the direct edit URL is more useful for review before publishing.
Step 5 — Build the YouTube Metadata Child Workflow
Create T6-Content-Child-YouTube as a 6-node workflow that generates YouTube SEO metadata and writes it to a Google Doc.- Add a When Called by Another Workflow trigger node; define one input field:
topic. - Add an AI / Claude node (model: Claude Haiku 4.5) named YouTube SEO:
- Connect it to a Structured Output Parser.
- The prompt must demand JSON-only output with fields:
title,description,tags,timestamps.
- Add a Code node named Format Doc Content to shape the parsed JSON into a readable Google Doc body string.
- Add a Google Docs node set to Create; note that the field holding the new document's ID in the output is
id— notdocumentId(a common wrong guess). - Add a second Google Docs node set to Update (Insert Text) to write the formatted content into the newly created document; reference the doc ID with
{{ $json.id }}. - Add a final Code node named Build YT Output; prefix all output fields with
yt_(e.g.,yt_title,yt_tags,yt_docUrl,processedBy_YouTube) to prevent field collisions when Merging with Blog child output later.
Tip — This child workflow generates text metadata only — it does not create or upload a video. Auto-injecting this metadata into an actual YouTube upload requires a separate step: update the child to also write into the T5-Video-Metadata Sheet, which the upload workflow reads from.
Step 6 — Fix "Model Output Doesn't Fit Required Format" in the Output Parser
If the Structured Output Parser throws this error, tighten the prompt before reaching for advanced fixes.- Edit the YouTube SEO node's system/user prompt to explicitly state: respond with JSON only, no markdown fences, no extra commentary, no trailing text.
- Test again — in most cases, this prompt strictness (Fix 1) resolves the error completely.
- The Auto-fixing Output Parser (Fix 2) is a more robust fallback that automatically retries malformed outputs. Keep this as a documented option for production hardening but do not implement it now unless Fix 1 fails.
Step 7 — Connect Both Children in the Parent Dispatch Workflow
Update T6-Content-Factory-Dispatch to fan out to both child workflows in parallel and merge their results.- After the Limit node, draw two separate wires — one to Call Child Blog and one to Call Child YouTube.
- Set both Execute Sub-workflow nodes to Run once for each item so each topic spawns both children.
- Add a Merge node after both children; set its mode to Combine by Position.
- Connect both child output wires into the Merge node, then connect Merge to the Mark Done node.
- Test with one topic (e.g., "Top 5 amenities at Vinhomes Global Gate") and confirm:
- Merge outputs exactly 1 item.
- The item contains both blog fields and
yt_-prefixed YouTube fields with no overwrites.
Production tip — The yt_ prefix on all YouTube child output fields is what prevents Merge from overwriting blog fields that share the same name (e.g., both children might output a title). Always prefix child outputs when multiple children feed a single Merge node.
Key Lessons from This Session
- DALL-E 2 and DALL-E 3 are permanently gone. Any workflow using those models must migrate to
gpt-image-1— there is no fallback or grace period. - gpt-image-1 returns Base64, not a URL. Replace any "Download Image" node with a Code node that converts
data[0].b64_jsonto a binary field. - Draft Blogger posts do not return a real permalink. Build the edit URL manually from
blog.idandidinstead of relying on$json.url. - Google Docs Create node returns
id, notdocumentId. Always inspect raw output before writing expressions that reference node fields. - Prefix child output fields to avoid Merge collisions. Use a consistent naming convention like
yt_for all fields from the YouTube child workflow. - Prompt strictness fixes most Output Parser errors. Require JSON-only responses before reaching for the Auto-fixing Output Parser.
- Search before you fix, especially for API changes. When an AI tool suggests a fix for an API error, verify current model availability online first.
Conclusion:
In this n8n tutorial, we migrated image generation from the retired DALL-E to gpt-image-1, handled the Base64 response format correctly, fixed draft post field mappings, and built a parallel YouTube metadata child workflow — completing the core Content Factory. The next session focuses on production hardening: error output routing on each Execute Sub-workflow node, switching the parent trigger from Manual to Schedule, and linking an Error Handler workflow. If you have any questions, feel free to leave a comment below. Thank you!
Tags: n8n image generation AI, n8n tutorial, n8n workflow automation, gpt-image-1, n8n HTTP Request node, OpenAI image API, n8n sub-workflow, n8n Merge node
Maybe you are interested!
- Getting Started with n8n: Interface & Your First Manual Trigger
- n8n HTTP Request Node: Connect Any API Without Code
- Branching Workflows: IF, Switch & Merge Nodes in n8n
- n8n Expressions & Built-in Variables: The Complete Guide
- Comparing AI Models in n8n: Claude vs Gemini vs ChatGPT
- Connect Gmail to n8n: OAuth Setup & Reading Emails
- Build an AI Email Classifier with n8n
- Automated Email Digest to Telegram with n8n
- Google Sheets Automation with n8n: 4 Key Operations
- Auto-Generate Google Docs from Data with n8n