Filtering AI image generator output
Last updated Mon Nov 09 2026 00:00:00 GMT+0000 (Coordinated Universal Time)
Generated images are often stylised, so the art flag matters: decide whether illustrated nudity is acceptable for your audience.
from sfwapi import SfwApi
api = SfwApi(api_key=os.environ["SFWAPI_KEY"])
png_bytes = image.tobytes_png() # your pipeline's PNG encoder
r = api.analyze_bytes(png_bytes, policy={"block_level": 2, "block_sex_objects": True, "art": "block_from_3"})
if r["policy"]["blocked"]:
regenerate_or_blur()Batch tip: generated images compress well as WebP; a 1024×1024 WebP is a few hundred kilobytes, so bandwidth and surcharge are never a concern.