Generate and Edit Images with OpenAI in n8n

Discover how to automate image creation and editing using OpenAI’s powerful API integrated with n8n. This workflow enables seamless generation and modification of images, saving you time and boosting creative productivity.
manualTrigger
httpRequest
convertToFile
+1
Workflow Identifier: 1581
NODES in Use: Manual Trigger, HTTP Request, Convert JSON to File, Sticky Note

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Automation Does

This workflow creates and edits images automatically using OpenAI’s gpt-image-1 model.
It stops designers from spending long time doing small repeated edits.
You get new images made from text, then the workflow changes them as asked.
It works by sending prompts to OpenAI, turning base64 data into real files, then sending those back for editing.
The final output is a PNG image ready to use.


Tools and Services Used

  • OpenAI API: For generating and editing images.
  • n8n: Automation platform to build and run the workflow.

Inputs, Processing, and Outputs

Inputs

  • Manual trigger to start the workflow.
  • Text prompts describing the image to create and how to edit it.

Processing Steps

  • Send a POST request to OpenAI image generation endpoint with a prompt.
  • Convert the returned base64 image data into a binary PNG file.
  • Send that PNG file with a new prompt to OpenAI’s image editing endpoint.
  • Convert edited base64 data into a downloadable PNG.

Outputs

  • Final edited PNG image file, ready for download or use.

Who Should Use This Workflow

Designers or creators who need quick edits to images made from text.
Anyone spending too much time on small changes like adding masks or details.
This helps save time and makes editing less technical.


Beginner Step-by-Step: How to Use This Workflow in n8n

Step 1: Importing the Workflow

  1. Download the workflow file using the Download button on this page.
  2. Open your n8n editor.
  3. Click “Import from File” and choose the downloaded workflow.

Step 2: Set Up Credentials and Configurations

  1. Add your OpenAI API Key credentials in n8n.
  2. Check if there are IDs, emails, channels, or table names to update for your needs.
  3. Review text prompts inside nodes and change them if you want different images or edits.

Step 3: Test the Workflow

  1. Run the workflow manually using the Manual Trigger node to check it works.
  2. Look at the output image file in the last node.

Step 4: Activate for Production

  1. When tests succeed, switch the workflow ON to run when triggered.
  2. Consider using webhooks or chat triggers for automatic start.

If you want to host n8n yourself, see self-host n8n for options.


Customization Ideas

  • Change the image prompt to any description to make different images.
  • Update the editing prompt to add different details like hats, smiles, or accessories.
  • Change the image size for smaller or bigger images.
  • Add a mask file if you want to edit only parts of an image.
  • Use other triggers like chat bots to create images from user input.

Common Problems and Fixes

  • 401 Unauthorized error: Check your OpenAI API Key in n8n credentials.
  • No binary file found in editing step: Confirm the base64-to-file node uses correct property data[0].b64_json.
  • Edited image looks the same as original: Use clear detailed text in the edit prompt.

Pre-Production Checklist

  • Verify OpenAI API Key and available quota.
  • Run manual tests to ensure smooth node execution.
  • Check file conversions output proper PNG binary.
  • Review prompts for clear generation and editing instructions.
  • Save a backup of workflow JSON before big changes.

Deployment Guide

After test success, toggle the workflow ON.
Replace the manual start with webhooks or chat triggers for real user use.
Watch OpenAI usage and n8n logs to avoid errors or high costs.


Summary of Benefits and Results

→ Saves hours by automating repeated image edits.
→ Reduces errors caused by manual file handling.
→ Lets users create and edit images using simple text.
→ Outputs ready-to-use PNG files.
→ Can extend to automatic triggers for more uses.


Frequently Asked Questions

A 401 error occurs when the OpenAI API Key is missing, invalid, or not set correctly in n8n credentials.
This happens if the previous node did not output the image binary properly or used the wrong property instead of data[0].b64_json.
Editing prompts should be clear, detailed, and specific about desired changes to get noticeable edits in images.
The workflow works with one image per run. To edit many images, use batch controls or schedule multiple executions.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free