Skip to main content

Guardrails Concepts — Safety and Guardrails

← Back to Dashboard
1. Guardrails Concepts2. Policy Testing and Failure Modes

Guardrails Concepts

📚 Safety and Guardrails⏱ 11 min⭐ 75 XP⌨ Hands-on lab

Defense Layers Around the Model

Amazon Bedrock Guardrails is a configurable, model-agnostic safety layer you can attach to any inference call via guardrailConfig or run standalone via ApplyGuardrail (no model invocation needed). It ships six safeguard types:

  • Multimodal content filters (text + images) - hate, insults, sexual, violence, misconduct, and prompt-attack detection across both text prompts/outputs and uploaded or generated images, with per-category strength tuning.
  • Denied topics - natural-language descriptions of subjects to block entirely before or after generation.
  • Word filters - exact-match custom word/phrase blocklists (e.g. competitor names, profanity).
  • Sensitive information filters (PII redaction) - managed PII entity detectors (SSN, email, credit card, health IDs) plus custom regex, with BLOCK or ANONYMIZE masking actions.
  • Contextual grounding checks - score RAG outputs on both grounding (is the claim derived from retrieved Knowledge Base chunks?) and relevance (does it answer the user's prompt?).
  • Automated Reasoning checks - translate natural-language compliance policies into formal mathematical logic, proving with up to 99% verification accuracy whether model outputs satisfy business and regulatory rules rather than relying on probabilistic guesses.

Attaching a Guardrail to Converse (boto3)

response = client.converse(
    modelId="us.anthropic.claude-sonnet-5-5",
    messages=[{"role": "user", "content": [{"text": user_prompt}]}],
    guardrailConfig={
        "guardrailIdentifier": "gd-ent-prod-01",
        "guardrailVersion": "1",
        "trace": "enabled",   # inspect exact policy verdicts in response["trace"]
    },
)

Guardrails ship in Classic and Standard safeguard tiers (Standard extends detection into code elements like comments and identifiers), support cross-Region inference distribution, and can be enforced cross-account. Do not rely on model behavior alone for safety-critical decisions.

⌨ HANDS-ON LABCreate and Audit Bedrock Safety Guardrail
⭐ +150 XP

Deploy an Amazon Bedrock Guardrail enforcing PII redaction and sensitive topic content filters.

1Describe the active enterprise security guardrail.
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 1 — type "hint" if stuck
🧪 Knowledge Check
Press 1-4 to select1 of 3
What is a primary purpose of guardrails?
Speed up VPC networking
Apply policy controls on prompt/response content
Replace IAM roles
Provision databases