Router.Moderations
Create a Moderation
Analyze text for content policy violations using the moderation model and return classification results.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.router.moderations.create(input=["Some text to moderate"], model="openai/omni-moderation-latest")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.router.moderations.create({
input: ["Some text to moderate"],
model: "openai/omni-moderation-latest",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"input": Union[str, List[str]], # required
"model": str, # required
}
{
input: string | string[]; // required
model: string; // required
}
Show Response
Show Response
{
"id": str,
"model": str,
"results": List[Union[Results1, Results2]],
}
{
id: string;
model: string;
results: (Results1 | Results2)[];
}
Show Variant types
Show Variant types
Results1
{
"flagged": bool,
"categories": {
"hate": bool,
"hate_threatening": bool,
"harassment": bool,
"harassment_threatening": bool,
"illicit": bool,
"illicit_violent": bool,
"self_harm": bool,
"self_harm_intent": bool,
"self_harm_instructions": bool,
"sexual": bool,
"sexual_minors": bool,
"violence": bool,
"violence_graphic": bool,
},
"category_scores": {
"hate": float,
"hate_threatening": float,
"harassment": float,
"harassment_threatening": float,
"illicit": float,
"illicit_violent": float,
"self_harm": float,
"self_harm_intent": float,
"self_harm_instructions": float,
"sexual": float,
"sexual_minors": float,
"violence": float,
"violence_graphic": float,
},
"category_applied_input_types": { # optional
"hate": List[str],
"hate_threatening": List[str],
"harassment": List[str],
"harassment_threatening": List[str],
"illicit": List[str],
"illicit_violent": List[str],
"self_harm": List[str],
"self_harm_intent": List[str],
"self_harm_instructions": List[str],
"sexual": List[str],
"sexual_minors": List[str],
"violence": List[str],
"violence_graphic": List[str],
},
}
{
flagged: boolean;
categories: {
hate: boolean;
hateThreatening: boolean;
harassment: boolean;
harassmentThreatening: boolean;
illicit: boolean;
illicitViolent: boolean;
selfHarm: boolean;
selfHarmIntent: boolean;
selfHarmInstructions: boolean;
sexual: boolean;
sexualMinors: boolean;
violence: boolean;
violenceGraphic: boolean;
};
categoryScores: {
hate: number;
hateThreatening: number;
harassment: number;
harassmentThreatening: number;
illicit: number;
illicitViolent: number;
selfHarm: number;
selfHarmIntent: number;
selfHarmInstructions: number;
sexual: number;
sexualMinors: number;
violence: number;
violenceGraphic: number;
};
categoryAppliedInputTypes?: {
hate: string[];
hateThreatening: string[];
harassment: string[];
harassmentThreatening: string[];
illicit: string[];
illicitViolent: string[];
selfHarm: string[];
selfHarmIntent: string[];
selfHarmInstructions: string[];
sexual: string[];
sexualMinors: string[];
violence: string[];
violenceGraphic: string[];
};
}
Results2
{
"categories": {
"sexual": bool,
"hate_and_discrimination": bool,
"violence_and_threats": bool,
"dangerous_and_criminal_content": bool,
"selfharm": bool,
"health": bool,
"financial": bool,
"law": bool,
"pii": bool,
},
"category_scores": {
"sexual": float,
"hate_and_discrimination": float,
"violence_and_threats": float,
"dangerous_and_criminal_content": float,
"selfharm": float,
"health": float,
"financial": float,
"law": float,
"pii": float,
},
}
{
categories: {
sexual: boolean;
hateAndDiscrimination: boolean;
violenceAndThreats: boolean;
dangerousAndCriminalContent: boolean;
selfharm: boolean;
health: boolean;
financial: boolean;
law: boolean;
pii: boolean;
};
categoryScores: {
sexual: number;
hateAndDiscrimination: number;
violenceAndThreats: number;
dangerousAndCriminalContent: number;
selfharm: number;
health: number;
financial: number;
law: number;
pii: number;
};
}