Guardrails AI applies validators around an LLM pipeline to screen user inputs, sanitize sensitive data, enforce business policies, and constrain generated outputs. Multilayer protection lets output guards catch violations that bypass input filtering. section 13.3.1
Figure 13.6 Multilayered safety guardrails architecture diagram showing input guards, LLM processing, and output guards workflow
Use the architecture as an operational pattern: validate and sanitize the request, run LLM processing, then validate the response before returning it. section 13.3.1
Validate and sanitize user input
Install validators from the Guardrails Hub, configure access, and compose them with Guard().use_many(). A competitor validator can raise an exception on detection, while GuardrailsPII can fix matching email addresses, credit-card numbers, or SSNs. Call input_guard.validate(user_input) before expensive LLM processing and return validated_output only after successful validation. section 13.3.1

