Skip to content

Guardrails API ​

Endpoint for evaluating content against guardrail rules.

Hook plane (September 2026)

Guardrails now attach at six lifecycle hooks (prompt.pre, input.pre, output.pre, output.stream.delta, tool.pre, tool.post) across nine policy families, each with its own enforce/monitor mode. The /evaluate contract below is unchanged; see the Guardrails guide for the hook model and the full family list.

Evaluate ​

POST /api/client/v1/guardrails/evaluate

Request ​

json
{
  "guardrail_key": "pii-checker",
  "text": "My email is john@example.com and my phone is 555-0100"
}

Parameters ​

FieldTypeRequiredDescription
guardrail_keystringYesKey of the guardrail to evaluate
textstringYesContent to evaluate

Response ​

json
{
  "passed": false,
  "guardrail_key": "pii-checker",
  "guardrail_name": "PII Checker",
  "action": "flag",
  "findings": [
    { "category": "email", "message": "Email address detected", "block": false },
    { "category": "phone", "message": "Phone number detected", "block": false }
  ],
  "message": null
}

Response Fields ​

FieldDescription
passedtrue if no findings triggered, false otherwise
guardrail_keyKey of the evaluated guardrail
guardrail_nameDisplay name
actionConfigured action: block, flag, or redact
findingsArray of detected issues
messageOptional message for blocked content

Policy Families ​

FamilyEvaluation Method
Personal data (PII)Regex-based pattern matching (15 categories)
CredentialsPattern + entropy matching
Word FilterDeterministic list/regex matching
ModerationLLM classifier
Prompt ShieldLLM classifier (prompt injection detection)
Tool AccessDeterministic tool allow/deny policy

A guardrail's type (preset vs custom) is separate from its policy families — custom runs an LLM judged against your own rule text instead of the bundled families above.

Inference Integration ​

Guardrails can be attached to models and evaluated automatically during chat completions. When a guardrail blocks a request, the chat API returns:

json
{
  "error": {
    "type": "guardrail_block",
    "guardrail_key": "pii-checker",
    "action": "block",
    "findings": [...]
  }
}

Errors ​

StatusDescription
400Missing guardrail_key or text
401Invalid API token
404Guardrail not found

Studio · Pulse · Console · Agent SDK and more — the Cognipeer documentation hub