# Integrating Anthropic Claude API with Amazon Bedrock: A Complete Developer Guide

> Integrate Anthropic Claude with Amazon Bedrock using the AnthropicBedrock client. This guide simplifies API calls with automatic AWS SigV4 signing for developers.

- Repository: [Anthropic/prompt-eng-interactive-tutorial](https://github.com/anthropics/prompt-eng-interactive-tutorial)
- Tags: how-to-guide
- Published: 2026-03-09

---

**You can integrate Anthropic Claude with Amazon Bedrock by using the `AnthropicBedrock` client from the official Python SDK, which automatically handles AWS SigV4 signing and exposes the same Messages API used in direct Anthropic API calls.**

The `anthropics/prompt-eng-interactive-tutorial` repository provides a complete Bedrock edition that demonstrates integrating Anthropic Claude API with Amazon Bedrock through hands-on Jupyter notebooks. This implementation allows developers to leverage Claude's advanced reasoning capabilities while utilizing AWS infrastructure for enterprise-grade security and scalability.

## How the AnthropicBedrock Client Works

The integration centers on the **`AnthropicBedrock`** class, a thin wrapper around AWS Bedrock's `InvokeModel` API. As implemented in the tutorial notebooks under `AmazonBedrock/anthropic/`, this client automatically handles SigV4 request signing and payload formatting required by AWS.

When you instantiate `AnthropicBedrock(aws_region=AWS_REGION)`, the SDK discovers AWS credentials from your runtime environment—whether through environment variables, AWS config files, or a SageMaker execution role. The client then builds Bedrock request payloads matching Claude's Messages API schema, allowing seamless migration between direct Anthropic API calls and Bedrock deployments.

## Environment Setup and Configuration

### Installing the Required SDK

The repository pins the exact SDK version in [`AmazonBedrock/requirements.txt`](https://github.com/anthropics/prompt-eng-interactive-tutorial/blob/main/AmazonBedrock/requirements.txt) to ensure compatibility with the latest Bedrock APIs:

```text
anthropic==0.21.3

```

Install this dependency in your virtual environment before running any notebooks:

```bash
pip install -r AmazonBedrock/requirements.txt

```

### Configuring AWS Credentials

The `AnthropicBedrock` client supports standard AWS credential chains. You can authenticate via:

- **Environment variables**: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and optionally `AWS_SESSION_TOKEN`
- **AWS config files**: Credentials stored in `~/.aws/credentials` and `~/.aws/config`
- **SageMaker execution role**: When using the provided CloudFormation template, the notebook instance assumes a role with `AmazonBedrockFullAccess`

### Automated Deployment with CloudFormation

For production-ready environments, the repository includes [`AmazonBedrock/cloudformation/workshop-v1-final-cfn.yml`](https://github.com/anthropics/prompt-eng-interactive-tutorial/blob/main/AmazonBedrock/cloudformation/workshop-v1-final-cfn.yml). This template provisions a SageMaker notebook instance pre-configured with:

- IAM role granting `AmazonBedrockFullAccess`
- Encrypted storage via KMS
- Pre-installed dependencies from [`requirements.txt`](https://github.com/anthropics/prompt-eng-interactive-tutorial/blob/main/requirements.txt)

## Implementing the Bedrock Messages API

The tutorial implements a reusable helper function `get_completion` in `AmazonBedrock/anthropic/01_Basic_Prompt_Structure.ipynb` (lines 42-52). This function encapsulates the `client.messages.create` call with Bedrock-specific parameters.

Here is the complete implementation pattern:

```python
import os
from anthropic import AnthropicBedrock

# Configure region and model identifier

AWS_REGION = os.getenv("AWS_REGION", "us-east-1")
MODEL_NAME = "anthropic.claude-3-haiku-20240307-v1:0"

# Initialize the Bedrock client

client = AnthropicBedrock(aws_region=AWS_REGION)

def get_completion(user_prompt: str, system: str = "") -> str:
    """
    Send a prompt to Claude via Bedrock and return the text response.
    """
    response = client.messages.create(
        model=MODEL_NAME,
        max_tokens=1024,
        temperature=0.0,
        messages=[{"role": "user", "content": user_prompt}],
        system=system,
    )
    # response.content is a list of text blocks; join them for convenience

    return "".join(block.text for block in response.content if hasattr(block, "text"))

# Example usage

if __name__ == "__main__":
    system_prompt = "You are a concise technical assistant."
    user_query = "Explain the difference between precision and recall."
    
    answer = get_completion(user_query, system=system_prompt)
    print(answer)

```

**Critical implementation details:**

- **Model identifiers** for Bedrock use the full ARN suffix format (e.g., `anthropic.claude-3-haiku-20240307-v1:0`), not the short names used in the direct Anthropic API.
- **The `system` parameter** accepts a string that sets Claude's behavior across the conversation, implemented as a top-level parameter in the Messages API.
- **Response parsing** requires iterating over `response.content` blocks, as Bedrock returns content as a list of text blocks rather than a single string.

## Key Repository Files for Bedrock Integration

The `anthropics/prompt-eng-interactive-tutorial` repository organizes Bedrock-specific resources under the `AmazonBedrock/` directory:

- **[`AmazonBedrock/requirements.txt`](https://github.com/anthropics/prompt-eng-interactive-tutorial/blob/main/AmazonBedrock/requirements.txt)** – Pins `anthropic==0.21.3` to ensure the `AnthropicBedrock` client is available.
- **`AmazonBedrock/anthropic/01_Basic_Prompt_Structure.ipynb`** – Contains the foundational `get_completion` helper and demonstrates client initialization.
- **[`AmazonBedrock/cloudformation/workshop-v1-final-cfn.yml`](https://github.com/anthropics/prompt-eng-interactive-tutorial/blob/main/AmazonBedrock/cloudformation/workshop-v1-final-cfn.yml)** – Infrastructure-as-code for deploying a SageMaker environment with pre-configured Bedrock permissions.
- **[`AmazonBedrock/utils/hints.py`](https://github.com/anthropics/prompt-eng-interactive-tutorial/blob/main/AmazonBedrock/utils/hints.py)** – Supporting utilities for tutorial exercises, packaged with the Bedrock edition.

## Summary

Integrating Anthropic Claude API with Amazon Bedrock requires understanding the `AnthropicBedrock` client wrapper and the Bedrock-specific Messages API implementation:

- **Use `AnthropicBedrock`** from the `anthropic` Python SDK to handle AWS SigV4 signing and endpoint management automatically.
- **Reference the correct model identifiers** (e.g., `anthropic.claude-3-haiku-20240307-v1:0`) when calling `client.messages.create`.
- **Leverage the `get_completion` pattern** established in `AmazonBedrock/anthropic/01_Basic_Prompt_Structure.ipynb` to standardize API calls across your application.
- **Deploy via CloudFormation** to provision SageMaker instances with the necessary `AmazonBedrockFullAccess` IAM permissions and encrypted storage.

## Frequently Asked Questions

### What is the difference between AnthropicBedrock and the standard Anthropic client?

The **`AnthropicBedrock`** client is a specialized wrapper that routes requests through Amazon Bedrock's `InvokeModel` API rather than directly to Anthropic's API endpoints. It automatically handles AWS SigV4 request signing, uses Bedrock-specific model identifiers (ARN suffixes), and discovers credentials through standard AWS credential chains. The standard `Anthropic` client connects directly to `api.anthropic.com` and requires an Anthropic API key.

### Which Claude models are available through Amazon Bedrock?

Amazon Bedrock supports multiple Claude model versions, including Claude 3 Haiku, Claude 3 Sonnet, and Claude 3 Opus, as well as Claude 2 and Claude 2.1. When using the `AnthropicBedrock` client, you must specify the full model identifier string, such as `anthropic.claude-3-haiku-20240307-v1:0` or `anthropic.claude-3-sonnet-20240229-v1:0`. These identifiers correspond to the ARN suffixes used in the Bedrock console and API.

### How do I handle authentication when running Claude on Bedrock in a SageMaker notebook?

When deploying via the provided CloudFormation template ([`AmazonBedrock/cloudformation/workshop-v1-final-cfn.yml`](https://github.com/anthropics/prompt-eng-interactive-tutorial/blob/main/AmazonBedrock/cloudformation/workshop-v1-final-cfn.yml)), the SageMaker notebook instance assumes an IAM execution role that includes the `AmazonBedrockFullAccess` policy. The `AnthropicBedrock` client automatically discovers these credentials through the AWS SDK's default credential provider chain. If running locally, you must configure credentials via environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`) or the `~/.aws/credentials` file with appropriate Bedrock invocation permissions.

### Can I use the same prompt engineering techniques from the direct API when calling Claude through Bedrock?

Yes, the prompt engineering techniques demonstrated in the `anthropics/prompt-eng-interactive-tutorial` repository apply identically whether using the direct Anthropic API or Amazon Bedrock. The `get_completion` helper function in `AmazonBedrock/anthropic/01_Basic_Prompt_Structure.ipynb` accepts the same parameters: `user_prompt`, `system` prompts, `max_tokens`, and `temperature`. The Bedrock integration uses the same Messages API schema, ensuring consistent behavior for chain-of-thought prompting, few-shot examples, and structured output techniques across both deployment options.