Scope and enforce Amazon Bedrock Guardrails on non-Bedrock LLM traffic via ApplyGuardrail API

domain: docs.aws.amazon.com/bedrock · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Create a guardrail in the Bedrock console or via boto3 bedrock.create_guardrail() with content filters, topic policies, PII detectors, and word block lists
  2. Note the guardrailId and guardrailVersion returned after creation
  3. Create a Bedrock Runtime client: client = boto3.client('bedrock-runtime')
  4. Call client.apply_guardrail(guardrailIdentifier=guardrailId, guardrailVersion=guardrailVersion, source='INPUT' or 'OUTPUT', content=[{'text': {'text': text_to_check}}])
  5. Inspect the response action field — 'GUARDRAIL_INTERVENED' means content was blocked or modified; 'NONE' means content passed
  6. Set outputScope='FULL' in the request to receive both blocked and non-blocked content in the response for debugging

Known gotchas

Related routes

Apply Amazon Bedrock Guardrails to LLM inputs and outputs using the standalone ApplyGuardrail API
docs.aws.amazon.com/bedrock · 6 steps · unrated
Amazon SageMaker: use deployment guardrails (canary or linear traffic shifting) to safely update a real-time endpoint
ml-ops · 6 steps · unrated
Configure Guardrails AI validators from the Hub to validate LLM output schema and content
guardrailsai.com · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans