spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

Support image moderation in OpenAI

Open habuma opened this issue 7 months ago • 0 comments
trafficstars

OpenAI's moderation API currently offers two models:

  • text-moderation-latest (Legacy) - Supports only text moderation
  • omni-moderation-latest - Supports both text and image moderation

(See https://platform.openai.com/docs/guides/moderation)

While both of these work with Spring AI, Spring AI currently defaults to use text-moderation-latest.

I suggest two things:

  • Default to omni-moderation-latest
  • Apply changes to support moderation of images as well as text, if supported by the chosen model.

AFAICT, Mistral (the only other provider that Spring AI has a moderation model implementation for) only has one model: mistral-moderation-latest. (But they do have two separate endpoints, one for raw-text moderation and another for conversational moderation.)

When this issue has been resolved, I'd expect that text moderation would continue to work as-is. Image moderation would also work by default if using OpenAI (and fail appropriate if using the "text-moderation-latest" model or Mistral.

habuma avatar Apr 21 '25 20:04 habuma