Python
Getting Started

Get Started

bedrock-anthropic is a python library for interacting with Anthropic's models on AWS Bedrock. It makes it really easy to use Anthropic's models in your application.

Installation

Install bedrock-anthropic using pip.

pip install bedrock-anthropic

Authentication

This is the preferred way to use this SDK. Learn more about how you can get your access key and secrey key here.

import os
from bedrock_anthropic import AnthropicBedrock
 
anthropic = AnthropicBedrock(
    access_key=os.getenv("AWS_ACCESS_KEY"),
    secret_key=os.getenv("AWS_SECRET_KEY"),
    region=os.getenv("AWS_REGION")
)

Done!

You are all set to use the bedrock-anthropic Python SDK!

import os
from bedrock_anthropic import AnthropicBedrock
 
anthropic = AnthropicBedrock(
    access_key=os.getenv("AWS_ACCESS_KEY"),
    secret_key=os.getenv("AWS_SECRET_KEY"),
    region=os.getenv("REGION")
)
 
completion = anthropic.Completion.create(
    model="anthropic.claude-v2",
    prompt="In one sentence, what is good about the color blue?",
)
 
print(completion["completion"])

Continue reading the docs to learn more about this SDK.