Introduction to AWS Bedrock
Duration: 45 min
AWS Bedrock is a fully managed service that provides access to foundation models (FMs) via a simple API. Instead of managing infrastructure or fine-tuning models yourself, you invoke pre-trained models from leading AI companies like Anthropic, Meta, Mistral, and Stability AI. This module covers what Bedrock is, the models available, pricing, and real-world use cases.
What is AWS Bedrock?
Bedrock abstracts away the complexity of deploying and managing foundation models. You get:
- No infrastructure management — AWS handles scaling, availability, and updates
- Multiple model providers — Claude, Llama, Mistral, Titan, Stable Diffusion in one place
- Simple API — Invoke models with a few lines of Python
- Security & compliance — Data stays in your AWS account; no model training on your data by default
Foundation Models Explained
A foundation model is a large neural network trained on massive amounts of text, code, or images. They're "foundational" because they can be adapted to many downstream tasks without retraining from scratch.
Key characteristics:
- Trained on billions of parameters
- Learned from diverse, unlabeled data
- Can perform multiple tasks (text generation, summarization, Q&A, code generation)
- Improved with prompt engineering and fine-tuning
Bedrock Pricing Model
Bedrock uses on-demand pricing (pay per token) or provisioned throughput (reserved capacity):
{
"on_demand": {
"claude_3_sonnet": {
"input_tokens": "$0.003 per 1K tokens",
"output_tokens": "$0.015 per 1K tokens"
},
"llama_2_70b": {
"input_tokens": "$0.00195 per 1K tokens",
"output_tokens": "$0.00256 per 1K tokens"
}
},
"provisioned_throughput": {
"description": "Reserve capacity for predictable workloads",
"commitment": "1 or 6 month terms",
"discount": "Up to 40% savings vs on-demand"
}
}Common Use Cases
1. Customer Support Chatbots
- Automated Q&A with company knowledge bases
- Reduced support ticket volume
- 24/7 availability
2. Content Generation
- Blog posts, product descriptions, marketing copy
- Personalized email campaigns
- Code generation and documentation
3. Data Analysis & Insights
- Summarize documents and reports
- Extract key information from unstructured data
- Generate business intelligence
4. Code Assistance
- Code review and refactoring suggestions
- Bug detection and fixes
- Documentation generation
5. Retrieval-Augmented Generation (RAG)
- Answer questions using private data
- Reduce hallucinations with grounded context
- Build domain-specific AI assistants
Getting Started with Bedrock
Prerequisites
# Install AWS CLI v2
curl "https://awscli.amazonaws.com/awscli-exe-macos.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
# Install boto3
pip install boto3
# Configure AWS credentials
aws configureEnable Model Access
Models in Bedrock are disabled by default. Enable them in the AWS Console:
# List available models
aws bedrock list-foundation-models --region us-east-1
# Or enable via console: Bedrock > Model access > Request accessFirst API Call
import boto3
client = boto3.client('bedrock-runtime', region_name='us-east-1')
response = client.invoke_model(
modelId='anthropic.claude-3-sonnet-20240229-v1:0',
body=json.dumps({
"anthropic_version": "bedrock-2023-06-01",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "What is AWS Bedrock?"
}
]
})
)
result = json.loads(response['body'].read())
print(result['content'][0]['text'])Bedrock vs Alternatives
| Feature | Bedrock | OpenAI API | Self-hosted |
|---|---|---|---|
| Model choice | Multiple providers | GPT only | Any model |
| Data privacy | Stays in AWS | Sent to OpenAI | Full control |
| Setup time | Minutes | Minutes | Hours/days |
| Cost predictability | On-demand or reserved | On-demand only | Infrastructure costs |
| Compliance | AWS compliance | Limited | Full control |
❓ What is the primary advantage of AWS Bedrock?
❓ Which pricing model offers up to 40% savings?
❓ What must you do before using a model in Bedrock?
❓ Which use case is NOT mentioned as a Bedrock strength?