Introduction to Amazon Bedrock
Nikhil Rangarajan
Data Scientist
Note: Throughout this course, Access Key
and Secret Key
have been pre-loaded.
'us-east-1'
)# Not secure for production, only for teaching purposes AWS_REGION = 'us-east-1'
AWS_ACCESS_KEY = 'your-access-key'
AWS_SECRET_KEY = 'your-secret-key'
'bedrock-runtime'
for model inferenceimport boto3
bedrock = boto3.client('bedrock-runtime', # use -runtime
region_name=AWS_REGION,
aws_access_key_id=AWS_ACCESS_KEY,
aws_secret_access_key=AWS_SECRET_KEY)
'bedrock'
for operational requests
# Verify Bedrock client configuration import boto3 bedrock_client = boto3.client('bedrock', region_name='us-east-1')
models = bedrock_client.list_foundation_models() print(f"Connected successfully! Found {len(models['modelSummaries'])} available models.")
Connected successfully! Found 13 available models.
get_foundation_model()
to retrieve model details
amazon.nova-micro-v1:0
, anthropic.claude-3-5-sonnet-v2:0
response = bedrock_client.get_foundation_model
(modelIdentifier='anthropic.claude-3-5-sonnet-v2:0')
print(response)
{ 'modelDetails': {
'modelName': 'anthropic.claude-3-5-sonnet-v2:0', 'modelId': 'anthropic.claude-3-5-sonnet-v2:0', 'providerName': 'Anthropic', 'modelArn': 'arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-3-5-sonnet',
'inputModalities': ['TEXT'], 'outputModalities': ['TEXT'], 'responseStreamingSupported': True, 'inferenceTypesSupported': ['ON_DEMAND'], 'modelLifecycle': {'status': 'ACTIVE'}
} }
Introduction to Amazon Bedrock