Guardrail Call
The guardrail_call function validates input using a guardrail. This allows you to check content against various safety rules directly within a workflow.
- Function name:
extensions.com.cloud-apim.llm-extension.guardrail_call
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
kind | string | yes | The guardrail kind (see available guardrails below) |
config | object | yes | The guardrail configuration |
input | string/object/array | yes | The input to validate |
Available guardrail kinds
regex- Regular expression matchingwebhook- External webhook validationllm- LLM-based validationsecrets_leakage- Detect secrets leakageauto_secrets_leakage- Automatic secrets leakage detectiongibberish- Detect gibberish contentpif- Detect personal informationmoderation- Language moderationmoderation_model- Model-based moderationtoxic_language- Detect toxic languageracial_bias- Detect racial biasgender_bias- Detect gender biaspersonal_health_information- Detect personal health informationprompt_injection- Detect prompt injection attemptsfaithfulness- Check response faithfulnesssentences- Validate sentence countwords- Validate word countcharacters- Validate character countcontains- Check if text contains specific contentsemantic_contains- Semantic containment checkquickjs- QuickJS scripted validationwasm- WASM-based validation
Output
{
"pass": true
}
or
{
"pass": false,
"cause": "reason for denial"
}
Example
{
"kind": "call",
"function": "extensions.com.cloud-apim.llm-extension.guardrail_call",
"args": {
"kind": "regex",
"config": {
"deny": [".*credit card.*", ".*password.*"]
},
"input": "Hello, how are you?"
},
"result": "guardrail_result"
}