n8n

How to Automate OpenAI Image Production?

Turn short text prompts into ready image files in a few clicks. Built for marketing teams that need fast visuals for ads, social posts, and product pages. The build produces consistent images that are easy to store or share.

It starts with a manual test button. A Set step holds your prompt, model, image count, size, and quality. An HTTP request sends these details to OpenAI and gets a list of base64 image strings. A Split step turns that list into separate items, and a Convert step changes each base64 string into a binary image file. You finish with clean files that can flow into storage, a CMS, or a review step.

You only need an OpenAI account with an API key and a simple credential in n8n. Expect batch image creation on demand and cut manual API testing from 15 minutes to about 1 minute per batch. Great for ad variant ideas, blog headers, and quick concept art. Click Test workflow, review outputs, then connect a storage or publishing node when you are ready.

What are the key features?

  • Manual test trigger lets you run image creation on demand
  • Set Variables stores prompt, model, size, quality, and image count in one place
  • HTTP Request calls the OpenAI Images API with JSON body and headers
  • SplitOut separates the returned data array into one item per image
  • Convert to File turns each b64_json string into a binary image file
  • Uses an OpenAI API credential saved in n8n for secure requests

What are the benefits?

  • Reduce manual image generation work from 15 minutes to about 1 minute per batch
  • Generate multiple images per click based on your selected count
  • Keep size and quality consistent across every file
  • Remove base64 copy and paste tasks entirely
  • Create ready to store binary files for your CMS or drive

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with OpenAI. See the Tools Required section above for links to create accounts with these services.
  3. In your OpenAI account, create an API key from the API keys page and copy it to your clipboard.
  4. In the n8n credentials manager, create a new OpenAI credential. Paste the API key, give the credential a clear name, and save.
  5. Open the OpenAI HTTP Request node. In the Credential to connect with dropdown, select your OpenAI credential. Confirm method is POST and the URL is https://api.openai.com/v1/images/generations with Content-Type set to application/json.
  6. Open the Set Variables node. Enter your image_prompt, choose the openai_image_model name, set number_of_images, and choose size_of_image and quality_of_image values.
  7. Check the Separate Image Outputs node. Make sure it splits the field named data so each image is processed alone.
  8. Open the Convert to File node. Confirm the operation is toBinary and the sourceProperty is b64_json.
  9. Click Test workflow to run. In the OpenAI node output, verify you see a data array with b64_json values.
  10. Open the Separate Image Outputs node output. Confirm you see one item per image.
  11. Open the Convert to File node output. Confirm each item now has a binary file you can pass to storage or email nodes.
  12. If you get an error, check the API key, confirm the model name supports image generation, reduce the number_of_images if needed, and make sure the prompt is present.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

Credits:
YouTube video

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.