Example

from phi.agent import Agent, RunResponse
from phi.model.aws.claude import Claude

agent = Agent(
    model=Claude(id="anthropic.claude-3-5-sonnet-20240620-v1:0")
)

# Get the response in a variable
# run: RunResponse = agent.run("Share a 2 sentence horror story.")
# print(run.content)

# Print the response on the terminal
agent.print_response("Share a 2 sentence horror story.")

Usage

Get your keys from here.

1

Create a virtual environment

Open the Terminal and create a python virtual environment.

python3 -m venv ~/.venvs/aienv
source ~/.venvs/aienv/bin/activate
2

Install libraries

pip install -U boto3 phidata
3

Export Environment Variables

  export AWS_ACCESS_KEY_ID=***
  export AWS_SECRET_ACCESS_KEY=***
  export AWS_DEFAULT_REGION=***
4

Run AWS Bedrock Agent

python cookbook/providers/bedrock/basic.py

Information