Skip to main content
1

Create a Python file

touch azure_openai.py
2

Add the following code to your Python file

azure_openai.py
from agno.agent import Agent
from agno.models.azure.openai_chat import AzureOpenAI

agent = Agent(model=AzureOpenAI(id="o1"))
agent.print_response(
    "Solve the trolley problem. Evaluate multiple ethical frameworks. "
    "Include an ASCII diagram of your solution.",
    stream=True,
)
3

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
4

Install libraries

pip install -U openai agno
5

Set your Azure OpenAI credentials

  export AZURE_OPENAI_API_KEY="xxx"
  export AZURE_OPENAI_ENDPOINT="xxx"
  export AZURE_DEPLOYMENT="xxx"
6

Run Agent

python azure_openai.py