Calling Claude through Bedrock slightly differs from how you would call Claude when using Anthropic’s client SDK’s. This guide will walk you through the process of completing an API call to Claude on Bedrock in either Python or TypeScript.

Note that this guide assumes you have already signed up for an AWS account and configured programmatic access.

Install and configure the AWS CLI

  1. Install a version of the AWS CLI at or newer than version 2.13.23
  2. Configure your AWS credentials using the AWS configure command (see Configure the AWS CLI) or find your credentials by navigating to “Command line or programmatic access” within your AWS dashboard and following the directions in the popup modal.
  3. Verify that your credentials are working:
Shell
aws sts get-caller-identity

Install an SDK for accessing Bedrock

Anthropic’s client SDKs support Bedrock. You can also use an AWS SDK like boto3 directly.

Accessing Bedrock

Subscribe to Anthropic models

Go to the AWS Console > Bedrock > Model Access and request access to Anthropic models. Note that Anthropic model availability varies by region. See AWS documentation for latest information.

API model names

ModelBedrock API model name
Claude 3 Haikuanthropic.claude-3-haiku-20240307-v1:0
Claude 3 Sonnetanthropic.claude-3-sonnet-20240229-v1:0
Claude 3 Opusanthropic.claude-3-opus-20240229-v1:0
Claude 3.5 Haikuanthropic.claude-3-5-haiku-20241022-v1:0
Claude 3.5 Sonnetanthropic.claude-3-5-sonnet-20241022-v2:0

List available models

The following examples show how to print a list of all the Claude models available through Bedrock:

Making requests

The following examples shows how to generate text from Claude 3 Sonnet on Bedrock:

See our client SDKs for more details, and the official Bedrock docs here.

Was this page helpful?