Topic 3 of 6 · 4 min read
Prompt templates for consistent product imagery
Goal: Build a prompt template that keeps style and layout consistent across a batch while user-supplied details vary safely.
A prompt template fixes everything the brand controls (style, layout, lighting, rules) in text you wrote, and leaves small, validated slots for the parts that change per request.
Check yourself · 1 of 3
Which part of an image prompt belongs in the fixed template and not in a user slot?
Why it matters
If every request is hand-written, a catalogue of 500 product images comes back in 500 styles. If the user's text is the whole prompt, users also override your style and your safety rules. A template makes output repeatable, makes cost predictable and makes problems easier to trace.
How to do it
- Split fixed and variable. Fixed: style, camera angle, background, lighting, aspect ratio, what to avoid. Variable: the product name, a colour, a short scene detail.
- Write the template as one block with named slots. For example
{{subject}},{{colour}},{{scene}}. Keep it in version control with a version id, and log the version with every generated image. - Validate slot values before filling them. Limit length, allow a set of characters or a list of known options, and strip anything that looks like an instruction ("ignore the rules above"). A dropdown beats free text wherever you can use one.
- Be careful with text inside images. Models still misspell. If the image must carry a headline or a price, draw that text in code over the generated image, or keep it short and check it.
- Pin the seed or settings where the provider allows it. Same template, same size, same quality; changing them changes the look.
- Check a batch for drift. Generate a fixed set of test subjects for each template version. Compare them side by side, then measure with simple checks: size, background colour near the corners, a logo present, no extra text.
Before and after
Before:
{{user_text}}
After (template v3):
Studio product photo of {{subject}} in {{colour}}.
Centered, filling 70% of the frame, soft top light, plain white background.
No text, no logos, no people, no shadows on the background.
Flat, realistic style, same as our catalogue.
With subject = "ceramic mug" and colour = "forest green", every request keeps the same look and only the allowed details change.
What goes wrong
- The user text is pasted as the whole prompt and ignores your style.
- A template change ships without a test batch, and a week of new images quietly shifts in style.
- The prompt asks for a slogan inside the image, and one in ten comes back misspelled.
- Slots accept free text of any length, so a user types a paragraph that overrides the fixed rules.
Examples
Slots with allowed values
const COLOURS = ["forest green", "navy", "cream"] as const;
function fill(subject: string, colour: string) {
if (!COLOURS.includes(colour as any)) throw new Error("bad colour");
const s = subject.slice(0, 60).replace(/[^\w\s-]/g, "");
return TEMPLATE_V3.replace("{{subject}}", s).replace("{{colour}}", colour);
}
The colour comes from a list, and the subject is trimmed and stripped of symbols.
A drift check
Keep ten fixed subjects. When template v3 becomes v4, generate all ten with both. Look at them side by side, then check automatically that each image is the expected size and that the corner pixels are near white. A failed check blocks the release.
Key points
- A template fixes what the brand controls and exposes only small named slots.
- Validate and limit slot values; use fixed options instead of free text where possible.
- Version every template and store the version id with each generated image.
- Draw exact text in code over the image instead of trusting the model's lettering.
- Run a fixed test batch on every template change and compare for drift.
Common mistakes
- Using the user's whole text as the prompt, which overrides the brand style.
- Changing a template without regenerating a fixed test batch.
- Expecting exact spelling of slogans or prices drawn by the model.
- Allowing unlimited free text in a slot.
Check yourself · 2 of 3
A team changes its template and ships the same day. A week later, product images look warmer and more cropped. What process would have caught this?
Check yourself · 3 of 3
An image must show the headline "SALE 20% OFF". What is the most dependable way to get exact lettering?
Practice items, not counted towards your mastery.
Start here
- Image generation guide (OpenAI) (opens in a new tab)DocsFree
Size, quality, edit and mask parameters for the OpenAI image endpoints.
- Image generation with Gemini (Google) (opens in a new tab)DocsFree
Gemini's text-to-image and conversational editing, including reference images and its watermark note.
- FLUX documentation (Black Forest Labs) (opens in a new tab)DocsFree
How the FLUX API submits a job and returns a polling address instead of the image.
Where to go in your country
- Article 50: Transparency obligations (EU AI Act) (opens in a new tab)DocsFreeEU
Marking duty for providers of generated content and disclosure duty for deepfakes.