// 1) Create or update a Prompt Security 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",
threshold: 0.9 // L1 (Confident). Use 0.8 for L2, 0.7 for L3, 0.6 for L4
detector: {
model: "modern-guard",
target: "user",
}
})
});
// 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: "..." }],
policy: "prompt-defense"
})
});