Moderations
Create chat moderation
Classify chat messages for harmful content
/v1/chat/moderationsClassifies messages in a conversation for harmful content. Unlike /v1/moderations, this endpoint accepts chat messages and supports a scope parameter to control which messages are evaluated.
Not compatible with the OpenAI SDK. Use /v1/moderations for SDK compatibility.
Authorizations
Authorizationstringrequired
Your authentication credentials. Pass your API key as a Bearer token: Bearer $INWORLD_API_KEY. You can create a key in one command with the Inworld CLI: inworld workspace add-key.
Body
application/jsonmessagesobject[]required
Array of chat messages to classify.
Show child attributes
roleenum<string>required
The role of the message author.
Available options:systemuserassistanttool
contentoneOf
The content of the message. Can be a string for text-only messages, an array of content parts for multimodal messages, or null for assistant messages with tool_calls.
tool_callsobject[]
Tool calls generated by the model (assistant messages only).
Show child attributes
idstringrequired
ID of the tool call.
typeenum<string>required
The type of the tool call. Always 'function'.
Available options:function
functionobjectrequired
The function that the model called.
Show child attributes
namestringrequired
The name of the function to call.
argumentsstringrequired
The arguments to call the function with, as a JSON string.
tool_call_idstring
Tool call ID this message is responding to (tool role only).
scopeoneOfdefault: "last"
Which messages to classify. "last" (default) processes only the last message. "all" processes every message. A positive integer N processes the last N messages. Be mindful that including many messages increases response latency.
modelstringdefault: "inworld/moderation-latest"
The moderation model to use.