-
Notifications
You must be signed in to change notification settings - Fork 1
Guardrails Integrations
Krishna Kishor Tirupati edited this page Jul 23, 2026
·
1 revision
PolicyAware can orchestrate NeMo Guardrails, Guardrails AI, or custom internal validators as part of one governed AI execution flow.
PolicyAware remains the control plane:
- deny-by-default policy
- risk classification
- model routing
- audit traces
- evaluation
- compliance evidence
- local code scanning
Guardrails libraries become optional adapters:
- NeMo Guardrails for conversational rails and dialog safety.
- Guardrails AI for structured output validation and validators.
- Custom guards for internal enterprise validation.
Base install:
pip install policyawareOptional guardrails integrations:
pip install "policyaware[nemo]"
pip install "policyaware[guardrails-ai]"
pip install "policyaware[full]"| API | Purpose |
|---|---|
GuardrailResult |
Normalized allow/block/transform result. |
GuardrailAdapter |
Adapter protocol for input and output guards. |
NeMoGuardrailsAdapter |
Optional adapter for NVIDIA NeMo Guardrails. |
GuardrailsAIAdapter |
Optional adapter for Guardrails AI. |
Gateway.add_input_guard(...) |
Run guard before model routing/execution. |
Gateway.add_output_guard(...) |
Run guard after model output. |
Gateway.add_guard(...) |
Run the same guard for input and output phases. |
PolicyAware policies can declare guard usage as policy-as-code.
id: full_stack_guardrails_policy
schema_version: "0.2"
default: deny
guards:
input:
- name: nemo
config_path: rails/
when:
request.task_type: chatbot
output:
- name: guardrails_ai
rail_spec: guardrails/spec.rail
when:
request.output_format: json
rules:
- name: allow_support
effect: allow
when:
user.role_in: [support_agent, developer]
request.risk_in: [low, medium]Known guard names:
| Guard Name | Adapter |
|---|---|
nemo |
NeMoGuardrailsAdapter |
nemoguardrails |
NeMoGuardrailsAdapter |
guardrails_ai |
GuardrailsAIAdapter |
guardrails-ai |
GuardrailsAIAdapter |
guardrails |
GuardrailsAIAdapter |
For internal enterprise validators, add custom: true in YAML and register the guard object in Python.
guards:
input:
- name: internal_safety
custom: true
when:
request.task_type: chatbotfrom policyaware import Gateway, GatewayRequest, GuardrailResult, PolicyEngine
class InternalSafetyGuard:
name = "internal_safety"
def inspect_input(self, request: GatewayRequest) -> GuardrailResult:
if "forbidden action" in request.prompt_text.lower():
return GuardrailResult(
name=self.name,
allowed=False,
reason="Blocked by internal safety guard.",
score=0.0,
)
return GuardrailResult(name=self.name)
def inspect_output(self, request: GatewayRequest, output_text: str) -> GuardrailResult:
return GuardrailResult(name=self.name)
gateway = Gateway(
policy_engine=PolicyEngine.from_file("policy.yaml"),
guard_registry={"internal_safety": InternalSafetyGuard()},
)from policyaware import Gateway, GatewayRequest, NeMoGuardrailsAdapter
gateway = Gateway.from_policy_file("policy.yaml")
gateway.add_input_guard(
NeMoGuardrailsAdapter(config_path="rails/")
)
response = gateway.chat(
GatewayRequest(
tenant="acme",
app="chatbot",
user={"id": "u_123", "role": "support_agent"},
context={"region": "us", "risk": "low", "task_type": "chatbot"},
messages=[{"role": "user", "content": "Help me with this account question."}],
)
)
print(response.policy.decision)
print(response.metadata["guardrails"])from policyaware import Gateway, GatewayRequest, GuardrailsAIAdapter
gateway = Gateway.from_policy_file("policy.yaml")
gateway.add_output_guard(
GuardrailsAIAdapter(rail_spec="guardrails/spec.rail")
)
response = gateway.chat(
GatewayRequest(
tenant="acme",
app="structured-output-agent",
user={"id": "u_456", "role": "analyst"},
context={
"region": "us",
"risk": "medium",
"task_type": "structured_output",
"output_format": "json",
},
messages=[{"role": "user", "content": "Return a validated JSON summary."}],
)
)
print(response.content)
print(response.metadata["guardrails"])List guards declared in a policy:
policyaware guards list examples/full-stack-guardrails/policy.yamlRun the full-stack guardrails demo:
cd examples/full-stack-guardrails
python demo.pyExpected output:
decision=allow
content=validated output
input_guard=demo_guard
output_guard=demo_guard
GatewayRequest
-> data protection
-> ML signals
-> risk classification
-> YAML policy decision
-> input guard adapters
-> model routing
-> model provider
-> output guard adapters
-> runtime evaluation
-> audit trace
-> GatewayResponse
Guard results are recorded in:
response.metadata["guardrails"]Shape:
{
"input": [
{
"name": "nemo",
"allowed": true,
"transformed_text": null,
"reason": "Allowed by NeMo Guardrails.",
"score": 1.0,
"metadata": {}
}
],
"output": [
{
"name": "guardrails_ai",
"allowed": true,
"transformed_text": null,
"reason": "Allowed by Guardrails AI.",
"score": 1.0,
"metadata": {}
}
]
}policyaware scan now checks guardrail usage too.
It detects:
- direct NeMo Guardrails / Guardrails AI usage outside PolicyAware orchestration
- NeMo guard policy missing
config_pathorconfig - Guardrails AI guard policy missing
rail_spec,rail, orspec - custom guard without
custom: true - guard policy without a
whencondition
Example:
policyaware scan . --format html,json,sarif,markdownFinding category:
Guardrails Integration
Compliance area:
Guardrails Orchestration
- Home
- Capabilities
- Copy-Paste Examples
- Comparison
- SEO And Distribution
- Feedback And Testimonials
- Adoption And Impact
- Contributing
- Roadmap
- Ready-To-Use YAML
- Data Protection
- Policy Enforcement
- Gateway Orchestration
- Risk Classification
- Model Routing and Providers
- Tool Governance
- Evaluation
- Audit and Observability
- Guardrails Integrations
- ML-Assisted Signals
- Local Code Scan
- Installation
- Quick Start
- Architecture
- CLI Reference
- ML Integrations
- Provider Adapter Examples
- YAML Policy Templates