Use 'BLOCK_LOW_AND_ABOVE' Only | Generated by AI

Home 2025.08

You’re seeing this error:

Only block_low_and_above is supported for safetySetting.

This happens when you set safety_filter_level="BLOCK_MEDIUM_AND_ABOVE" (or any other value) in GenerateImagesConfig for the Imagen‑4 models—but at the time of your request (August 2025), the API only allows "BLOCK_LOW_AND_ABOVE" for image safety filtering on those models (Google Cloud).


✅ How to fix your code

Simply update the safety_filter_level to the supported value:

from google import genai
from google.genai.types import GenerateImagesConfig

client = genai.Client()

image = client.models.generate_images(
    model="imagen-4.0-generate-preview-06-06",
    prompt="A dog reading a newspaper",
    config=GenerateImagesConfig(
        image_size="2K",
        number_of_images=1,
        safety_filter_level="BLOCK_LOW_AND_ABOVE",
        person_generation="ALLOW_ADULT",
    ),
)

image.generated_images[0].image.save("output-image.png")
print(
    f"Created image using {len(image.generated_images[0].image.image_bytes)} bytes"
)

🧾 Other optional parameters:


TL;DR — Quick checklist

Step What to do
✅ 1 Change safety_filter_level to "BLOCK_LOW_AND_ABOVE"
🧾 2 Keep person_generation="ALLOW_ADULT" (or omit for default)
🚫 3 Don’t use "BLOCK_MEDIUM_AND_ABOVE" or "BLOCK_ONLY_HIGH"
⏱ 4 Don’t change safety again until Google adds more levels

Let me know if you get another error—happy to help!


Back Donate