Prerequisites
Before configuring Bedrock guardrails in AI Studio, you need:- An AWS account with access to Amazon Bedrock
- A Bedrock guardrail created in the AWS console
- AWS credentials with permission to invoke the guardrail
- Enterprise plan access to AI Studio
Create a Bedrock guardrail in AWS
If you haven’t created a Bedrock guardrail yet, follow these steps in the AWS console:- Navigate to Amazon Bedrock > Guardrails in the AWS console
- Select Create guardrail
- Configure your guardrail policies:
- Content filters: Block harmful content categories (hate, insults, sexual, violence)
- Denied topics: Define custom topics to block
- Word filters: Block specific words or phrases
- Sensitive information filters: Detect and block PII types
- Contextual grounding: Check for hallucinations and relevance
- Save your guardrail and note the Guardrail ID and Version
Configuration parameters
Configure these parameters when adding a Bedrock guardrail in AI Studio:Required parameters
Optional parameters
AWS authentication options
AI Studio supports multiple AWS authentication methods for Bedrock guardrails.Access keys (recommended for getting started)
Use IAM user access keys for straightforward authentication:Temporary credentials (STS)
Use temporary credentials from AWS Security Token Service:IAM role assumption
Assume an IAM role for cross-account access or elevated permissions:Web identity (OIDC)
Use OIDC tokens for container-based or Kubernetes deployments:Required IAM permissions
The AWS credentials you provide must have permission to invoke your Bedrock guardrail. Create an IAM policy with the following permissions:Guardrail versioning
Bedrock guardrails support versioning, allowing you to test changes before applying them to production:
Recommended workflow:
- Test guardrail changes using
DRAFTversion in a development environment - Publish a new version in the AWS console when satisfied
- Update production AI Studio configuration to use the new version number
Bedrock guardrail capabilities
AWS Bedrock Guardrails provide several content filtering capabilities:Content filters
Block content based on harmful categories with configurable thresholds:- Hate: Discriminatory or prejudiced content
- Insults: Demeaning or offensive language
- Sexual: Sexually explicit content
- Violence: Violent or threatening content
- Misconduct: Content promoting illegal activities
- Prompt attacks: Attempts to manipulate the model
Denied topics
Define custom topics that should be blocked. Useful for:- Preventing discussion of competitors
- Blocking off-topic conversations
- Enforcing industry-specific restrictions
Sensitive information filters
Detect and block PII types including:- Names, addresses, phone numbers
- Email addresses, URLs
- Credit card numbers, bank accounts
- Social Security numbers (US)
- Driver’s license numbers
- Passport numbers
Word filters
Block specific words, phrases, or patterns. Supports:- Exact word matching
- Profanity filters
- Custom blocked terms
Error handling
When Bedrock blocks content, AI Studio returns an error to the agent. The default behavior raises an exception that halts the request. Setdisable_exception_on_block: true to return a modified response instead of raising an exception. This is useful for:
- Chat interfaces where exceptions disrupt the conversation
- Applications that need to handle blocks gracefully
- Scenarios where you want to show a custom message to users
Troubleshooting
Common errors
Verify your guardrail
Test your guardrail directly in the AWS console before configuring it in AI Studio:- Navigate to your guardrail in the AWS Bedrock console
- Select Test to open the testing interface
- Enter sample content that should trigger the guardrail
- Verify the guardrail blocks or allows content as expected
Next steps
- Configure guardrails: Learn about guardrail modes and scoping
- Usage and spend: Monitor guardrail activity and usage
- AWS Bedrock Guardrails documentation: Detailed AWS documentation
- Create a guardrail in AWS: Step-by-step AWS console instructions
- AWS Bedrock pricing: Understand Bedrock guardrail costs