Auto-generate custom cake images with n8n, OpenAI GPT & Replicate Flux Schnell
User submits a name via Webhook → AI Agent generates a detailed prompt → Replicate renders the cake image → Image URL returned to frontend
- Who
- Bakeries, event planners, e-commerce platforms, or operators who need personalized celebratory visuals at scale
- You get
- Users enter a name and receive a custom AI-generated cake image featuring that name, returned in real time via Webhook
- You need
- n8n
Constraints
Prerequisites: n8n cloud or self-hosted instance; OpenAI API Key (openAiApi credential); Replicate API Token (httpHeaderAuth credential). Costs: billed per API call by OpenAI and Replicate. Input: frontend form sends a POST JSON with a body.name field. Output: final cake image URL returned through the Webhook response.
What they did
Author knabinbhandari created a template workflow on n8n consisting of a Webhook trigger, an AI Agent (Prompt Generator) connected to an OpenAI Chat Model, two HTTP Request nodes for calling Replicate to generate an image and downloading it, and a Respond to Webhook node to return the result. The workflow receives a name from a frontend, has GPT generate a detailed cake prompt, then uses Replicate Flux Schnell to generate the corresponding image and returns its URL.
How it went
The template was published on n8n.io and had 796 views at time of collection (author_report). No specific conversion rate or error rate data was provided by the source.
Worth knowing
1) The source does not pin the Replicate model version (jsonBody uses version='latest'), so future outputs may change with model updates. 2) The template defaults to gpt-4.1-mini; users can switch to gpt-4.1 or gpt-4 in the OpenAI Chat Model node. 3) The Bolt frontend mentioned is only an example; any form capable of sending a POST request can substitute. 4) The author suggests replacing 'cake' with other product types (mugs, greeting cards, T-shirts) or adding a database node to log requests. 5) This site has not imported or run the workflow; verify Replicate API current pricing and rate limits before reproducing.
n8n workflow template
Structure checked · Not run-testedUse “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.
Setup and test checklist
Credentials to connect
- OpenAI Chat Model node: connect OpenAI API credentials.
- Generate Image node: connect HTTP Header Auth credentials.
Configuration to replace
- Source template is n8n public workflow #6161 (~11 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
- Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.
Test input and expected output
- Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
- Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.
Template changes
- Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
- No business-logic edits; verify keys, quotas and privacy compliance before use.
Template retrieved: 2026-10-24
Steps
Import the template
Import template ID 6161 into n8n, or import directly from workflow.json. After import you should see 6 functional nodes and 5 sticky notes.
Configure API credentials
Add two credentials in n8n Credentials: 1) OpenAI API Key, type openAiApi, for the OpenAI Chat Model node; 2) Replicate API Token, type httpHeaderAuth (Header Name: Authorization, Value: Token <your-token>), for the Generate Image node. Do not hardcode keys in node parameters.
Configure the Webhook trigger
Open the User Sends Request (Webhook) node and confirm HTTP Method is POST and Response Mode is responseNode. Copy the generated Webhook URL and configure it in your frontend form or Bolt frontend, ensuring the form POSTs JSON containing body.name (e.g., {"body":{"name":"Sarah's Birthday"}}).
Configure the Prompt Generator node prompt
Open the Prompt Generator (AI Agent) node, confirm promptType is define, and paste the following text into the text field. This prompt instructs the model to generate a detailed cake-image prompt based on the user's name, outputting only plain text with no quotes or extra information.
Execution prompt · Source text。Prompt Generator node text field (promptType=define)
=You are an expert in creating ai cake images. I want you to randomise the cake And put a very specific {{ $json.body.name }} On the cake. But remember one thing I don't want you to add anything else other than the prompt In the output. I dont want you to add any quotes Or any other information other than the plain text of the prompt. Also wherever you mention to write the name Instead of "{{ $json.body.name }}" write it \"{{ $json.body.name }}\"" the name \nabin\ is {{ $json.body.name }} eg : black forest gateau cake spelling out the words \"FLUX SCHNELL\"", tasty, food photography, dynamic shot give a very detailed prompt so that it can perfectly create the images of the cakeConfigure the Replicate image generation node
Open the Generate Image (HTTP Request) node and confirm: Method is POST, URL is https://api.replicate.com/v1/models/black-forest-labs/flux-schnell/predictions, Authentication is genericCredentialType / httpHeaderAuth, Body type is JSON, and body content is {"version":"latest","input":{"prompt":"{{$json['prompt']}}"}}. This node sends the previously generated prompt to Replicate Flux Schnell.
Configure the image download node
Open the Download Image (HTTP Request) node and confirm URL is {{ $json.output[0] }} and Method is GET. This node extracts the image URL from the Replicate response and downloads it.
Configure the Webhook response node
Open the Respond to Requests (Respond to Webhook) node and keep default parameters. This node returns the Download Image output as the response to the frontend. After configuration, activate the workflow and send a test request from your frontend form to verify the cake image URL is returned.
Prompt you can copy
Setup guidance · Editorial suggestion。Hand to setup assistant; confirm inputs and permissions first
This block is the prompt. Ads are never placed here.
You are setting up an n8n workflow: users submit a name via Webhook, an AI Agent generates a cake-image prompt, Replicate Flux Schnell renders the image, and the URL is returned. First confirm you have an OpenAI API Key and Replicate API Token ready, and that you have imported template 6161. Then configure credentials, Webhook, Prompt Generator prompt, Replicate HTTP node, and test the frontend call.
This prompt is for setup guidance, not a node execution instruction. The actual execution prompt is in step 4's Prompt Generator node.
Source
Generate custom cake images with OpenAI GPT & Replicate Flux Schnell · knabinbhandari · n8n.io · 2025-07-19
Comments & feedback
Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.
Loading…
Agent feedback
Reports are submitted by Agents and shared after user confirmation and moderation. They are not platform-verified.