← Back to Blog
Prompting • Oct 19, 2026

AI image editing prompts: a four-clause structure

A reusable four-clause structure for AI image editing prompts, covering background replacement, identity preservation, product edits, and multi-image inputs.

A precise AI image editing prompt is the difference between a clean background swap and a ruined portrait. The structure described below is a reusable template for edits requested through the Gemini image generation API and for the recipes listed on the Nano Banana prompt recipes page, which states that the seed, steps, guidance, and strength values it publishes are "starting points for compatible open-model pipelines" rather than API parameters.

The prompt structure that holds

When you ask for an edit, give the model four things in this order:

  1. Subject. Identify what is being edited: the person, product, or region. Use specific names or roles ("the woman in the red jacket").
  2. Change. State the one thing you want done ("replace background", "swap jacket to red leather").
  3. Preservation. Explicitly list what must stay ("preserve identity, hair, pose, lighting, geometry").
  4. Style guard. Add a quality boundary ("match scene lighting", "soft natural shadow", "no new text").

This order matters. The Gemini image generation documentation places the text prompt alongside one or more input images, and when chaining edits, you can pass a follow-up instruction through previous_interaction_id to keep refining the same image without restating the subject. That makes the subject and preservation clauses load-bearing across turns, while the change and style guard rotate with each new request.

Background replacement prompt

A background replacement prompt fails when the model also rewrites the subject's lighting or pose. The fix is to spell out preservation as a constraint, not as a wish. Compare two phrasings:

  • Weak: "Put her on a beach."
  • Strong: "Replace the background with a sunny beach. Keep the subject, facial features, hair, and pose unchanged. Match the existing lighting direction and shadow falloff."

The Nano Banana identity consistency recipe reads: "keep character identity and facial features; change background to sunny beach, match lighting and shadows", and pairs the prompt with an open-model starting point of seed=21, steps=28, guidance=4.0, strength=0.55. The recipes page is explicit that those four values are starting points for compatible open-model pipelines, not Gemini API parameters, so do not copy them into a Gemini API call. Use the prompt text; use your usual diffusion settings in your local pipeline.

For Gemini image edits, the documentation shows the request built as an input array containing separate entries: a text entry with the prompt and an image entry carrying the base64-encoded image data and its MIME type. The Gemini image generation documentation also shows that every returned image carries a SynthID watermark and that you can steer toward a specific file type, aspect ratio, and size through the response_format parameter (mime_type, aspect_ratio, image_size).

Preserve identity AI image edit

Identity drift is a common failure mode of a character edit. Three structural habits help prevent it:

  1. Anchor the subject first. "the woman in image 1" or "the same character from the reference" outperforms "her" or "the person".
  2. List what must not change. Face, eye color, hair, body proportions, skin texture. The Nano Banana character tweak recipe demonstrates this with "keep face identity and hair" alongside a clothing change.
  3. Separate change from preservation. Never bundle them in the same sentence. The Gemini documentation notes that gemini-nano-banana-2.1 and gemini-3.1-flash-image support likeness for up to four characters and object precision for up to ten objects in one workflow, which only helps if your prompt lists each one explicitly.

For a product edit, the same logic applies. The Nano Banana product shadows recipe asks for "preserve geometry" alongside a white seamless background and a soft natural shadow, and lists an open-model starting point of seed=56, steps=26, guidance=4.2, strength=0.5.

A four-step workflow you can reuse

  1. State the subject. One noun phrase, optionally with a reference image slot.
  2. State the change. One verb phrase scoped to a region or attribute.
  3. List preservation clauses. Comma-separated, ordered from most fragile (identity) to most forgiving (background tone).
  4. Add the style guard. Lighting, shadow, texture, text rules, and any "do not" constraints.

For chained edits, send a focused follow-up through previous_interaction_id rather than rewriting the whole prompt. The Gemini documentation illustrates this with an infographic translation: the second interaction is just "Update this infographic to be in Spanish. Do not change any other elements of the image." The preservation clause carries the load, so the model does not redraw the layout it just produced.

For multi-image edits, label each input image's role in the prompt ("Image 1: subject; Image 2: style reference") and note the per-model guidance in the Gemini documentation: gemini-2.5-flash-image works best with three images, while gemini-3-pro-image supports five images with high precision and up to 14 images overall. These are performance recommendations, not necessarily hard maximum input limits. When text or logos need to appear inside the image, the same source notes that Gemini is better to generate text first and then request an image with that text.

When you need a working starting point rather than a blank page, anchor your prompt library in the Nano Banana prompt recipes and reuse the patterns from the top prompt recipes guide. For background replacement, identity preservation, and product geometry, the four-clause structure above gives you a consistent way to adapt those recipes into reusable prompts. See the Nano Banana FAQ for setup details.

Sources