Getting started with the AWS API - Amazon Bedrock

Getting started with the AWS API

This section describes how to set up your environment to make Amazon Bedrock requests through the AWS API. AWS offers the following tools to streamline your experience:

  • AWS Command Line Interface (AWS CLI)

  • AWS SDKs

  • Amazon SageMaker notebooks

If you plan to authenticate and access the AWS API directly through your setup, proceed to Get credentials to grant programmatic access to a user.

If you plan to use a SageMaker notebook, skip this section and proceed to Run example Amazon Bedrock API requests using an Amazon SageMaker notebook.

Install the AWS CLI or an AWS SDK

To install the AWS CLI, follow the steps at Install or update to the latest version of the AWS CLI.

To install an AWS SDK, select the tab that corresponds to the programming language that you want to use at Tools to Build on AWS. AWS software development kits (SDKs) are available for many popular programming languages. Each SDK provides an API, code examples, and documentation that make it easier for developers to build applications in their preferred language. SDKs automatically perform useful tasks for you, such as:

  • Cryptographically sign your service requests

  • Retry requests

  • Handle error responses

Get credentials to grant programmatic access to a user

Grant programmatic access to the Amazon Bedrock role that you created in I already have an AWS account by configuring credentials for authentication.

Users need programmatic access if they want to interact with AWS outside of the AWS Management Console. The way to grant programmatic access depends on the type of user that's accessing AWS.

To grant users programmatic access, choose one of the following options.

Which user needs programmatic access? To By

Workforce identity

(Users managed in IAM Identity Center)

Use temporary credentials to sign programmatic requests to the AWS CLI, AWS SDKs, or AWS APIs.

Following the instructions for the interface that you want to use.

IAM Use temporary credentials to sign programmatic requests to the AWS CLI, AWS SDKs, or AWS APIs. Following the instructions in Using temporary credentials with AWS resources in the IAM User Guide.
IAM

(Not recommended)

Use long-term credentials to sign programmatic requests to the AWS CLI, AWS SDKs, or AWS APIs.

Following the instructions for the interface that you want to use.

Try out some Amazon Bedrock API requests

Now that you've set up programmatic access for your Amazon Bedrock role, you can proceed to test out some basic Amazon Bedrock API operations in your method of choice:

After you explore these examples, you should familiarize yourself with the four Amazon Bedrock services by reading the main page of the Amazon Bedrock API reference. When you make a request to a Amazon Bedrock operation, check that you are using the correct endpoint for the service.