Get Started
New to Bedrock? Get up to speed in 5 steps.
Amazon Bedrock gives you access to hundreds of models from a single service.
Before you can call any model, Bedrock needs to know who you are.
In this tutorial we'll use an API key. You can generate one directly in the console and start calling models in under a minute. No AWS CLI setup or IAM configuration needed.
Generate an API key
- Sign in to the AWS Management Console and open the Amazon Bedrock console
- In the left navigation panel, select API keys
- Choose either Generate short-term API key or Generate long-term API key
- For long-term keys, set your desired expiration time
- Choose Generate and copy your API key

- 2
Set the key in your environment
bashexport AWS_BEARER_TOKEN_BEDROCK="bedrock-api-key-..." - 3
Call Bedrock
boto3 detects the bearer token automatically. No extra config needed.
pythonimport boto3, json bedrock = boto3.client("bedrock-runtime", region_name="us-east-1") resp = bedrock.invoke_model( modelId="global.anthropic.claude-sonnet-4-6", body=json.dumps({ "messages": [{"role": "user", "content": "Hello, Bedrock!"}], "max_tokens": 512, }), ) print(json.loads(resp["body"].read()))
You can use Bedrock API keys to quickly test your setup.
For setups that require a higher level of security, we recommend using temporary IAM credentials. see security best practices in IAM for more details.
Find your model's ID and available Regions in the model cards, then call it.
import boto3, json
bedrock = boto3.client("bedrock-runtime", region_name="us-east-1")
resp = bedrock.invoke_model(
modelId="us.anthropic.claude-sonnet-4-6",
body=json.dumps({
"messages": [{"role": "user",
"content": "Hello, Bedrock!"}],
"max_tokens": 512,
}),
)
print(json.loads(resp["body"].read()))Bedrock offers multiple APIs to fit your needs. See APIs supported by Bedrock for more details
Add capabilities like guardrails, caching, and streaming to your API calls.
import boto3, json
bedrock = boto3.client("bedrock-runtime")
resp = bedrock.invoke_model(
modelId="anthropic.claude-sonnet-4-6",
body=json.dumps({
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 512,
"messages": [{"role": "user", "content": "Hello, Bedrock!"}],
}),
)
print(json.loads(resp["body"].read()))Nice work! You've got the fundamentals.
You authenticated, called a model, and added capabilities. Now you're ready to build with Bedrock.