Recipe: AI image safety validation - block uploads with nudity, gore, or suggestive content
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3585696. --> Reported by: [marcus_johansson](https://www.drupal.org/user/385947) >>> <p>[Tracker]<br> <strong>Update Summary: </strong>[One-line status update for stakeholders]<br> <strong>Short Description: </strong>Ship a recipe (ai_recipe_validations_image_safety) that validates uploaded images via AI vision and blocks uploads containing nudity, gore, or sexually suggestive content before they are saved.<br> <strong>Check-in Date: </strong>MM/DD/YYYY<br> [/Tracker]</p> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>Any Drupal site that accepts image uploads from users (community sites, marketplaces, membership platforms, open submissions) needs to screen those images for content that violates its safety policy. Without an automated check, unsafe images reach the public the moment the form is submitted, leaving moderators to clean up after the damage is done.</p> <p>The AI module already supports the <code>chat_with_image_vision</code> pseudo operation type (a chat call with an attached image), which lets any vision-capable provider (OpenAI GPT-4o, Anthropic Claude, Google Gemini, etc.) analyze an image and return a text assessment. What's missing is a ready-to-apply recipe that uses this capability to block uploads at validation time rather than reviewing them after the fact.</p> <p>The safety criteria should follow well-established community standards. Flickr's three-tier safety-level system (see <a href="https://www.flickrhelp.com/hc/en-us/articles/23250290741908-Guide-to-Safety-Levels">Flickr's Guide to Safety Levels</a>) is a useful reference:</p> <ul> <li><strong>Safe</strong> - content suitable for a global public audience.</li> <li><strong>Moderate</strong> - content that might not be suitable for all audiences (e.g. artistic nudity, mildly suggestive poses).</li> <li><strong>Restricted</strong> - content containing full nudity, explicit sexual content, graphic violence, or gore.</li> </ul> <p>For most Drupal sites, "Moderate" and "Restricted" content should be blocked at upload time. The recipe should default to blocking anything that falls outside "Safe", with a configuration surface to adjust the threshold.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Create a new drupal.org recipe project under the <code>ai_recipe_</code> prefix (suggested name: <code>ai_recipe_validations_image_safety</code>). When applied, image uploads are validated by AI before they are saved, and unsafe images are rejected with a user-facing error message.</p> <p><strong>Validation approach - entity validation constraint, not an automator:</strong></p> <ul> <li>This recipe should use <a href="https://www.drupal.org/project/ai_validations">AI Validations.</a>. This runs on upload either via ajax or on entity save.</li> <li>Make sure to check for chat with image vision existing before appyling</li> <li>Make sure to use the contrib space AI Validations and not the AI core one that is deprecated</li> </ul> <p><strong>Provider requirements:</strong></p> <ul> <li>Verify via <code>ai.settings.verifySetupAi</code> that the <code>chat_with_image_vision</code> pseudo operation type has a default model configured. Fail the recipe apply clearly if not.</li> <li>The recipe should be provider-agnostic - any provider that supports vision will work.</li> </ul> <h3 id="summary-ai-usage">AI usage (if applicable)</h3> <p>[x] AI Assisted Issue<br> This issue was generated with AI assistance, but was reviewed and refined by the creator.</p> <p>[ ] AI Assisted Code</p> <p>[ ] AI Generated Code</p> <p>[ ] Vibe Coded</p> <p>- <strong>This issue was created with the help of AI</strong></p> > Related issue: [Issue #3585699](https://www.drupal.org/node/3585699)
issue