AWS Builder Center

Getting Started with Amazon Bedrock: Building with Foundation Models

Explore how Amazon Bedrock simplifies access to foundation models without managing infrastructure. Learn about model access, API integration, IAM permissions, and common setup challenges through a practical walkthrough.

Getting Started with Amazon Bedrock: A Practical Developer Guide

Introduction

Generative AI development often involves more than simply choosing a model. Developers must consider infrastructure, authentication, scalability, security, and integration.
Amazon Bedrock simplifies this process by providing access to foundation models through a managed AWS service. Instead of provisioning GPU instances or maintaining model-serving infrastructure, developers can interact with supported models through APIs.
In this article, we will explore the fundamentals of Amazon Bedrock, how to configure access, and how developers can start experimenting with foundation models.

1. What is Amazon Bedrock?

Amazon Bedrock is a fully managed service from AWS that provides access to foundation models through a unified API.
It allows developers to experiment with different models and integrate generative AI capabilities into applications without managing the underlying infrastructure.
Some key capabilities include:
  • Model access: Work with supported foundation models from different providers.
  • Serverless experience: Avoid provisioning and maintaining model-serving infrastructure.
  • API integration: Connect models to applications using AWS SDKs and APIs.
  • Security: Integrate with AWS IAM for identity and access management.
  • Scalability: Build applications without managing the underlying model infrastructure.

2. Understanding the Architecture

A typical Amazon Bedrock application follows a straightforward architecture:
  1. A user submits a prompt through an application.
  1. The application sends a request to Amazon Bedrock.
  1. Bedrock processes the request using the selected foundation model.
  1. The model generates a response.
  1. The application receives and displays the generated output.
This architecture makes it possible to integrate generative AI into existing applications without hosting the model yourself.

3. Setting Up Amazon Bedrock

Before making API requests, a few configurations are required.

Step 1: Choose an AWS Region

Open the AWS Management Console and navigate to Amazon Bedrock.
Select a region where the required Bedrock features and models are available.
Model availability can vary by region, so verify the availability of your preferred model before proceeding.

Step 2: Configure Model Access

Navigate to the model catalog in Amazon Bedrock.
Explore the available foundation models and review their capabilities, supported regions, and usage requirements.
Depending on the model and account configuration, you may need to complete additional access requirements before invoking it.

Step 3: Configure IAM Permissions

AWS Identity and Access Management (IAM) controls which AWS resources your application can access.
For Bedrock, the identity used by your application needs appropriate permissions to invoke the selected model.
For example, the following IAM action is commonly required:
 bedrock:InvokeModel 
For streaming responses, you may also need:
 bedrock:InvokeModelWithResponseStream 
Use the principle of least privilege. Avoid granting broad permissions when a narrower policy is sufficient.

4. Making Your First API Request

Python developers can use the AWS SDK for Python, commonly known as Boto3.
Install the dependency:
pip install boto3
Configure your AWS credentials using an appropriate AWS authentication method.
For local development, AWS CLI profiles are one option:
aws configure
Then create a Bedrock Runtime client:
import boto3

client = boto3.client(
service_name="bedrock-runtime",
region_name="us-east-1"
)
The region above is an example. Choose a region that supports your selected model.
To invoke a model, use the  invoke_model  API with the model-specific request format:
import json
import boto3

client = boto3.client(
"bedrock-runtime",
region_name="us-east-1"
)

response = client.invoke_model(
modelId="YOUR_MODEL_ID",
body=json.dumps({
"YOUR_MODEL_SPECIFIC_REQUEST": "..."
}),
contentType="application/json",
accept="application/json"
)

result = json.loads(response["body"].read())

print(result)
Important: The request body and response structure depend on the selected foundation model. Replace the example payload with the schema documented for your chosen model.
Official documentation:  https://docs.aws.amazon.com/bedrock/ 

5. Common Setup Challenges

While experimenting with Amazon Bedrock, developers may encounter several configuration issues.

AccessDeniedException

Possible cause: The IAM identity does not have sufficient permissions.
What to check:
  • Verify the IAM policies attached to the identity.
  • Confirm that the required Bedrock actions are allowed.
  • Check whether the model requires additional access configuration.

ValidationException

Possible cause: The request contains invalid parameters or an unsupported model configuration.
What to check:
  • Verify the model ID.
  • Check the request body against the model's API documentation.
  • Confirm that the selected model supports the requested operation.

Model Not Available

Possible cause: The selected model is not available in the chosen AWS Region, or its access requirements have not been completed.
What to check:
  • Review regional model availability.
  • Verify model access requirements.
  • Check the model catalog in the selected region.

AWS Credentials Issues

Possible cause: The application cannot identify an authorized AWS identity.
What to check:
  • Verify your AWS CLI configuration.
  • Check the active AWS profile.
  • Confirm that the credentials have not expired.
  • Prefer IAM roles and temporary credentials over hardcoded access keys.

6. Security and Cost Considerations

Before deploying a Bedrock-powered application, consider the following:
  • Never hardcode AWS access keys in application source code.
  • Use IAM roles and temporary credentials wherever possible.
  • Apply least-privilege permissions.
  • Monitor usage through AWS billing and monitoring tools.
  • Review model pricing before selecting a model for production.
  • Avoid logging sensitive prompts or generated responses unnecessarily.
Remember that model invocation costs depend on the selected model, token consumption, and applicable pricing configuration.

7. Where Can You Use Amazon Bedrock?

Amazon Bedrock can support several application categories:
  • AI-powered chatbots and virtual assistants.
  • Document summarization and information extraction.
  • Retrieval-Augmented Generation (RAG) applications.
  • Automated content generation.
  • Enterprise knowledge assistants.
  • AI-powered developer tools.
Its managed approach makes it particularly useful when developers want to focus on application logic instead of model infrastructure.

Conclusion

Amazon Bedrock provides developers with a practical way to experiment with and integrate foundation models into real-world applications.
Understanding model availability, IAM permissions, API integration, and cost management is essential before moving from experimentation to production.
The best way to learn the service is to start with a small application, test a model, understand its API behavior, and gradually introduce more advanced capabilities.

Additional Resources

Happy building!
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article