Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

SafetyRatings returning undefined and finishReason return IMAGE_SAFETY even if safety image #21

@danieldeazevedo

Description

@danieldeazevedo

Description of the bug:

Hi, trying make a edit image and put a prompt to make something cool in image... but when in run returns: IMAGE_SAFETY in finishReason, but its just a picture of me... i try with other pictures.. sometimes works but the most block but i config SafetySettings in my code:

   const safetySettings = [
  {
    category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
    threshold: HarmBlockThreshold.BLOCK_ONLY_HIGH,
  },
        { 
            category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,            threshold:HarmBlockThreshold.BLOCK_ONLY_HIGH
     
        },
        {
category: HarmCategory.HARM_CATEGORY_CIVIC_INTEGRITY,
            threshold:HarmBlockThreshold.BLOCK_ONLY_HIGH,
        }    
];
    const model = genAI.getGenerativeModel({
        model: "gemini-2.0-flash-exp-image-generation",
        generationConfig: {
            responseModalities: ['Text', 'Image']
        },
        safetySettings: safetySettings,
    });

I already try with BLOCK_NONE but nothing works...
And other issue:

console.log(response.candidates[0].safetyRatings);

that's return:
undefined
I don't think this was supposed to be happening

Actual vs expected behavior:

When i run return IMAGE_SAFETY even if the image be a just simple photo and safety
And safetyRatings returns undefined
but in docs need return the reason category the probability and a boolean if blocked or no:

{
  "category": enum (HarmCategory),
  "probability": enum (HarmProbability),
  "blocked": boolean
}

Any other information you'd like to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions