Example
Use Claude
with your Agent
:
from phi.agent import Agent, RunResponse
from phi.model.anthropic import Claude
agent = Agent(
model=Claude(id="claude-3-5-sonnet-20240620"),
)
# 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
You can get your API key from Anthropic here.
Create a virtual environment
Open the Terminal
and create a python virtual environment.
python3 -m venv ~/.venvs/aienv
source ~/.venvs/aienv/bin/activate
Install libraries
pip install -U anthropic phidata
Export `ANTHROPIC_API_KEY`
export ANTHROPIC_API_KEY=xxx
Run Claude Agent
python cookbook/providers/claude/basic.py