// 1) Create or update a Grounding 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: "grounding-check",
definition: "Detect hallucinations and ungrounded claims",
threshold: 0.9, // L1 (Confident). Use 0.8 for L2, 0.7 for L3, 0.6 for L4
detector: {
model: "grounding",
target: "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: "context", content: "Our return policy allows returns within 14 days of purchase." }, // or "system" role
{ role: "user", content: "What is the return policy?" },
{ role: "assistant", content: "The return policy allows returns within 30 days." }
],
policy: "grounding-check"
})
});