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.
  1. 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 code model_not_found with the message "The model 'dall-e-3' does not exist" — there is no grace period.
  2. 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.
  3. 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.
  1. 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).
  2. In the HTTP Request node, set the Body to:
    • model: gpt-image-1
    • prompt: your prompt expression
    • size: 1024x1024
    • n: 1
  3. Remove any response_format field 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.
  1. 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.
  2. Delete (or disable) the Download Image node that previously performed a GET request on the image URL.
  3. Add a Code node named Base64 to Binary immediately after the HTTP Request node.
  4. Inside the Code node, write logic to:
    • Read $json.data[0].b64_json from the previous node's output.
    • Convert it to a binary buffer.
    • Return it as a binary field named data so downstream nodes (e.g., Google Drive upload) can consume it.
  5. 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.
  1. Run the Create Draft node against a real Blogger API call and inspect the raw output JSON.
  2. Confirm field mappings:
    • postId → use {{ $json.id }} (top-level field — this guess was correct).
    • blogId → use {{ $json.blog.id }}.
    • blogUrldo not use {{ $json.url }} for a draft. For a DRAFT post, url only returns the blog homepage, not a permalink.
  3. 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.
  1. Add a When Called by Another Workflow trigger node; define one input field: topic.
  2. 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.
  3. Add a Code node named Format Doc Content to shape the parsed JSON into a readable Google Doc body string.
  4. Add a Google Docs node set to Create; note that the field holding the new document's ID in the output is id — not documentId (a common wrong guess).
  5. 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 }}.
  6. 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.
  1. 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.
  2. Test again — in most cases, this prompt strictness (Fix 1) resolves the error completely.
  3. 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.
  1. After the Limit node, draw two separate wires — one to Call Child Blog and one to Call Child YouTube.
  2. Set both Execute Sub-workflow nodes to Run once for each item so each topic spawns both children.
  3. Add a Merge node after both children; set its mode to Combine by Position.
  4. Connect both child output wires into the Merge node, then connect Merge to the Mark Done node.
  5. 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

  1. 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.
  2. gpt-image-1 returns Base64, not a URL. Replace any "Download Image" node with a Code node that converts data[0].b64_json to a binary field.
  3. Draft Blogger posts do not return a real permalink. Build the edit URL manually from blog.id and id instead of relying on $json.url.
  4. Google Docs Create node returns id, not documentId. Always inspect raw output before writing expressions that reference node fields.
  5. Prefix child output fields to avoid Merge collisions. Use a consistent naming convention like yt_ for all fields from the YouTube child workflow.
  6. Prompt strictness fixes most Output Parser errors. Require JSON-only responses before reaching for the Auto-fixing Output Parser.
  7. 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!