Guardrails for Amazon Bedrock
Config-Driven Model Onboarding
Context
Bedrock provides LLM inference APIs across multiple models. Guardrails scans user queries and model responses for unwanted content, masking or blocking it with replacement messages.
Guardrails model selector across modalities
Problem
Guardrails needed to parse and write to LLM response text — but each model had a different schema. The existing approach was hardcoded if/else parsing logic per model, embedded in a Bedrock team-owned package. Every code change required their review and deployment cycle. Onboarding a new model with a schema change took an estimated 3 weeks.
Solution
Decoupled model-specific logic into config files loaded at runtime — but a naive 1:1 model-to-config mapping would still require 100+ configs at scale. Designed a two-level routing instead:
- Provider matching — route by provider (Anthropic, Meta, Cohere, etc.)
- Schema fingerprint — detect response structure at runtime from the LLM response (e.g.
messagesfield → v2,textfield → v1) to select the correct parsing config within that provider
This abstraction collapses hundreds of model IDs into a handful of provider × schema combinations, making bulk onboarding trivial.
Result
Onboarding time dropped from 3 weeks to config deployment. The two-level routing collapsed 100+ model IDs into ~8 provider × schema configs. Shipped 100+ Jumpstart catalog models for Guardrails at re:Invent 2024.