Gemini Image - Repeated Finish Reason: IMAGE_OTHER

Hi everyone,

I am facing an issue with gemini image API that I am unable to solve…

The deal is very simple, I have an image scene of a model and a logo image and want to insert the logo into the image.

I have this very weird behavior where 75% of the time the logo insertion fails and the reason returned is Finish Reason: IMAGE_OTHER.

As this reason is fairly vague, I am unable to find out what is the rootcause.

As you can see at the end of the post, images are fairly standard & don’t break any restriction.

As for the code, I don’t see much either, it’s fairly standard, no particular complexity related to gemini calls, just a production code which is fairly defensive but should not impact the image generation.

Below is the material I use.

Do you face the same issue?

Thanks for the insights

The code: Google Colab

The prompt is also standard I’d say:

##ROLE## You are a precision-focused Graphic Designer and Art Director. Your expertise is in placing graphical overlays onto finished images with taste and clarity. You do **not** alter the underlying image.

##CONTEXT##: You are provided with 2 images:

1. {logo_image}: A canva containing a logo

2. {reference_image}: A complex image / scene where the logo should be integrated,

## CORE DIRECTIVE: NON-DESTRUCTIVE & NON-INTRUSIVE PLACEMENT ##

Your task is to place the logo as a **clean, 2D graphical overlay** on top of the reference image.

The logo should look like it was added in a design program, not like it physically exists within the scene.

##INSTRUCTION##: Integrate the logo from {logo_image} into {reference_image} at the optimal position for maximum visual impact while maintaining the rest of the scene.

*Identify Safe Zone:** Analyze {reference_image} and identify a A SAFE ZONE to add the logo for maximum visual impact while maintaining the rest of the scene and composition

*Never create a background for the logo, the logo should be like it has a transparent background originally and should be added in the existing safe zone.

*Maintain the logo original design fidelity (typography, shape, proportions, etc.) as a pristine digital asset while allowed to modify the logo **scale** & **colors**

*You can change the logo **scale** & **colors** to ensure it will visually standout, ensuring visual harmony and maximum impact without compromising the original composition

#single_logo: Final image must contain exactly one logo instance with optimal visibility

#safety## If the logo isn’t inserted or not visible, regenerate the image.