Federico Mariani created CAMEL-23965:
----------------------------------------
Summary: camel-openai: add moderation operation
Key: CAMEL-23965
URL: https://issues.apache.org/jira/browse/CAMEL-23965
Project: Camel
Issue Type: New Feature
Components: camel-openai
Affects Versions: 4.21.0
Reporter: Federico Mariani
The pinned openai-java SDK (4.41.0) exposes
{{moderations().create(ModerationCreateParams)}}, but camel-openai has no
moderation operation. Moderation is the canonical pre-filter for untrusted
input on public-facing AI routes — rejecting policy-violating content *before*
spending chat tokens or triggering tool calls — and fits Camel's routing model
perfectly (content-based routing on the moderation verdict).
Proposal: new operation {{openai:moderation}}:
* body: String (or List of Strings for batch);
* options/headers: {{moderationModel}} (e.g. {{omni-moderation-latest}});
* output: body unchanged (pass-through style) with headers
{{CamelOpenAIModerationFlagged}} (Boolean), {{CamelOpenAIModerationCategories}}
(Map or JSON), {{CamelOpenAIModerationCategoryScores}}; full response via
{{storeFullResponse}}.
Pass-through body + verdict headers lets users do content-based routing on the
verdict without content juggling:
{code:java}
// guard a public-facing chat route: reject flagged input before spending chat
tokens
from("platform-http:/chat")
.to("openai:moderation?moderationModel=omni-moderation-latest")
.choice()
.when(header(OpenAIConstants.MODERATION_FLAGGED).isEqualTo(true))
.setBody(constant("Your message violates our usage policy."))
.otherwise()
.to("openai:chat-completion?model=gpt-5")
.end();
{code}
Cross-reference: CAMEL-23954 proposes moderation for camel-langchain4j-agent
via LangChain4j {{@Moderate}}; a native operation in camel-openai is simpler
(no annotated-interface machinery) and would give the OpenAI stack parity.
_This issue was drafted by Claude Code on behalf of Federico Mariani_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)