AWS Bedrock
Integrate AWS Bedrock foundation models with ModelRed
AWS Bedrock Foundation Models
Test managed foundation models from leading AI companies through AWS Bedrock's secure, scalable, and serverless platform.
Quick Setup
Get Started in 4 Steps
Connect AWS Bedrock foundation models for security testing.
Enable Bedrock Access
Enable access to foundation models in the AWS Bedrock Console.
Model Access → Request model access
Get AWS Credentials
Set up AWS IAM credentials with Bedrock permissions.
Access Key ID: AKIA...
Secret Access Key: ...
Region: us-east-1
Set Environment Variables
export AWS_ACCESS_KEY_ID="AKIA..."
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export AWS_DEFAULT_REGION="us-east-1"
Register Your Model
from modelred import ModelRed
async with ModelRed() as client:
await client.register_bedrock_model(
model_id="my-bedrock-claude",
bedrock_model_id="anthropic.claude-v2",
aws_access_key_id="AKIA...", # or use env vars
aws_secret_access_key="your-secret-key",
region="us-east-1"
)
Foundation Models
Claude v2
Anthropic's Claude with Constitutional AI
Llama 2
Meta's open-source Llama 2 models
Amazon Titan
Amazon's own foundation models
AI21 Jurassic
AI21 Labs' Jurassic foundation models
Cohere Command
Cohere's command and generation models
Stable Diffusion
Stability AI's image generation models
Configuration Options
Advanced Setup
Register different foundation models from Bedrock.
Multiple Models
# Register different Bedrock models
models = [
("claude-v2", "anthropic.claude-v2"),
("llama2-13b", "meta.llama2-13b-chat-v1"),
("titan-text", "amazon.titan-text-express-v1"),
("jurassic-ultra", "ai21.j2-ultra-v1")
]
for model_id, bedrock_id in models:
await client.register_bedrock_model(
model_id=model_id,
bedrock_model_id=bedrock_id,
region="us-east-1"
)
Regional Deployment
# Different regions for model availability
await client.register_bedrock_model(
model_id="claude-eu",
bedrock_model_id="anthropic.claude-v2",
region="eu-west-1",
metadata={
"region": "EU",
"compliance": "GDPR",
"use_case": "european_operations"
}
)
Enterprise Features
🏢 Bedrock Advantages
Serverless & Managed
No infrastructure management
Pay-per-request pricing
Security & Governance
Data never leaves AWS
VPC endpoint support
IAM fine-grained access
Model IDs Reference
📋 Popular Model IDs
Text Generation
anthropic.claude-v2
Claude v2
meta.llama2-13b-chat-v1
Llama 2 13B
amazon.titan-text-express-v1
Titan Express
ai21.j2-ultra-v1
Jurassic-2 Ultra
More Models
cohere.command-text-v14
Command v14
meta.llama2-70b-chat-v1
Llama 2 70B
amazon.titan-embed-text-v1
Titan Embeddings
stability.stable-diffusion-xl-v1
Stable Diffusion XL
Common Issues
⚠️ Troubleshooting
Model Access Denied
AccessDeniedException: No access to model
- • Request model access in Bedrock Console
- • Wait for access approval (can take time)
- • Check if model is available in your region
Invalid Model ID
ValidationException: Invalid model identifier
- • Use exact model IDs from Bedrock docs
- • Check model availability in your region
- • Verify model ID spelling and format
Insufficient Permissions
UnauthorizedOperation: User not authorized
- • Add bedrock:InvokeModel permission
- • Verify AWS credentials are correct
- • Check IAM policy allows Bedrock access
Quick Test
✅ Verify Your Setup
Run this test to confirm your Bedrock integration is working:
import asyncio
from modelred import ModelRed
async def test_bedrock():
async with ModelRed() as client:
# Register Bedrock model
await client.register_bedrock_model(
model_id="test-bedrock-claude",
bedrock_model_id="anthropic.claude-v2",
region="us-east-1"
)
print("✅ Bedrock model registered!")
# Run security test
result = await client.run_assessment(
model_id="test-bedrock-claude",
test_suites=["basic_security", "content_safety"]
)
print(f"🔍 Assessment started: {result.assessment_id}")
asyncio.run(test_bedrock())