// 1) Create or update a Content Moderation policy (check user + assistant)
await fetch("https://api.guardion.ai/v1/policies", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
},
body: JSON.stringify({
id: "content-moderation",
definition: "Classify and filter unsafe content",
target: "user",
detector: {
model: "moderation",
expected: "block",
threshold: 0.9,
reference: ["user", "assistant"]
}
})
});
// 2) Evaluate using that policy
const response = await fetch("https://api.guardion.ai/v1/guard", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
},
body: JSON.stringify({
messages: [{ role: "user", content: "..." }],
override_enabled_policies: ["content-moderation"]
})
});