// 1) Create or update a Prompt Defense policy
await fetch("https://api.guardion.ai/v1/policies", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
},
body: JSON.stringify({
id: "prompt-defense",
definition: "Prevent prompt injections and jailbreaks",
target: "user",
detector: {
model: "modern-guard",
expected: "block",
threshold: 0.9
}
})
});
// 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: ["prompt-defense"]
})
});