/api/v1/guardrails/generateGenerate guardrails from intent
Takes a natural-language safety intent (e.g., "Don't reveal customer SSNs") in `policyText` — or the SDK aliases `description` / `findings` — and uses an LLM to extract enforceable guardrail policies. Optional `category`, `action` (block/alert/redact) and `severity` set the defaults for generated rules. Returns `{guardrails, rawPolicies, confidence (0-1), skipped}`: each guardrail carries streaming-validator rules of type `keyword`, `regex` or `pii` with an action and severity (the `toxic` and `length` rule kinds exist in the validator but this generator never emits them) — regex patterns and keyword denylists, not scorer thresholds. `skipped` lists policy sentences that yielded no enforceable rule, so an inert rule is never reported as enforcement. 400 `MISSING_POLICY_TEXT` when empty, 400 `POLICY_TOO_LONG` above 50,000 characters. Requires the `firewall:check` scope on the API-key path and is rate-limited 10/min because it spends the org's BYOK OpenAI key (or the platform key). Generated rules require human review before deploy.
Authentication
Send Authorization: Bearer YOUR_API_KEY on every request. Generate API keys at /dashboard/settings/api-keys.
Request body required
Example
{
"policyText": "string",
"description": "string",
"category": "string",
"action": "string",
"severity": "string"
}Schema
{
"application/json": {
"schema": {
"type": "object",
"properties": {
"policyText": {
"type": "string",
"maxLength": 500000
},
"description": {
"type": "string",
"maxLength": 500000
},
"findings": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {}
},
{
"type": "object",
"additionalProperties": {}
}
]
},
"category": {
"type": "string",
"maxLength": 200
},
"action": {
"type": "string",
"maxLength": 200
},
"severity": {
"type": "string",
"maxLength": 200
}
},
"additionalProperties": {}
}
}
}Response
200 example
{
"success": true
}All status codes
Code samples
cURL
curl -X POST \
https://evalguard.ai/api/v1/guardrails/generate \
-H "Authorization: Bearer $EVALGUARD_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "policyText": "string", "description": "string", "category": "string", "action": "string", "severity": "string" }'TypeScript
// The TypeScript SDK (@evalguard/sdk) exposes TYPED methods — runEval,
// getEval, runSecurityScan, checkFirewall, … — not a generic request().
// For an arbitrary endpoint, call it directly:
const res = await fetch("https://evalguard.ai/api/v1/guardrails/generate", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.EVALGUARD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"policyText": "string",
"description": "string",
"category": "string",
"action": "string",
"severity": "string"
}),
});
console.log(res.status, await res.json());Python
# The Python SDK (pip install evalguardai) exposes TYPED methods on
# EvalGuardClient — run_eval, get_eval, … — not a generic request().
# For an arbitrary endpoint, call it directly:
import os
import requests
headers = {"Authorization": f"Bearer {os.environ['EVALGUARD_API_KEY']}"}
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://evalguard.ai/api/v1/guardrails/generate",
headers=headers,
json={
"policyText": "string",
"description": "string",
"category": "string",
"action": "string",
"severity": "string"
},
)
print(response.status_code, response.json())Go
package main
import (
"context"
"fmt"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{"policyText":"string","description":"string","category":"string","action":"string","severity":"string"}`)
req, _ := http.NewRequestWithContext(context.Background(), "POST", "https://evalguard.ai/api/v1/guardrails/generate", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("EVALGUARD_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
fmt.Println(resp.Status)
}