Automated AI Product Photography Studio

I built this for a small candle brand that had no time for product shoots, and it turned out general enough to share. You upload a plain product photo, pick a look, type one line about the scene, and it returns a styled studio-quality shot. Even though for this, I have a web front end and image server on the back end, the template linked below runs from a single n8n Form, so there’s no front end or server to host.

The form (4 fields):

- Pick a Photo (file upload)

- Photo Type: Flatlay, Hero Image, Ecommerce, Banner

- Aspect Ratio: 1:1, 9:16, 16:9, 4:5, 5:4, 21:9

- Describe the Scene (free text)

The flow:

`Form Trigger` → `Code` (file to base64) → `HTTP` upload to KIE.AI → `Set` (map fields) → `AI Agent` + `OpenAI Chat Model` (prompt enhancement) → `Set` (clean up) → `HTTP` create task → `Wait` → `HTTP` poll → `Code` (check state) → `IF` success/fail → `Form` completion screen with the image.

It uses Google’s nano-banana-2 (image-to-image) through KIE.AI. The model keeps the product exactly as-is and only re-renders the scene around it.

A few things that might help if you build something similar:

1. Getting a form file into an image-to-image model. nano-banana-2 wants an image URL, but a Form Trigger gives you a binary. A Code node turns the upload into a base64 data URL, then KIE.AI’s base64 upload endpoint (`/api/file-base64-upload`) hands back a temporary public URL you can feed straight into the model. No S3 or image host required.

2. A prompt-enhancement agent, not raw user text. The user types something like “springtime, light and airy, add lemon and grapefruit.” A small agent (gpt-4.1-mini) expands that into a dense photography prompt: surface and background material, lighting setup, camera angle, mood. The system prompt’s one hard rule is “describe the target scene, never the product itself,” which keeps the brand’s actual product intact.

3. Async generation behind a form. Image jobs take a bit, so it’s a simple poll loop: `Create Task` → `Wait 5s` → `Poll` → `Code` checks `state` → `IF` routes to success, failure, or back to the wait. The Form completion node then shows the finished image on the same form the user submitted.

Setup: two credentials, a KIE.AI HTTP Bearer key (on the three KIE.AI HTTP nodes) and an OpenAI key (on the chat model). Activate, open the form URL, done.

Two things I’d love input on:

- KIE.AI result URLs are temporary. For a fully self-contained template I left persistence out, but curious how others handle “save the output somewhere permanent” cleanly inside one workflow.

- Any slicker pattern than the Wait/IF poll loop for long-running async API jobs in n8n? I keep reaching for this shape and wonder what others do.

Happy to answer questions on any of the nodes.

YouTube walkthrough HERE

Grab the template HERE

1 Like

The Wait + HTTP poll pattern for KIE.AI’s async task is the right approach - much cleaner than trying to force a synchronous response from a long-running job. One thing worth adding: a max-retry counter in the loop to avoid the workflow hanging indefinitely if KIE.AI returns an unexpected state. A simple counter in the Set node each cycle + an IF check to break out after N attempts keeps it production-safe.

1 Like

Max retry logic is already built in!