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
from agno.tools.yfinance import YFinanceTools

agent = Agent(
    model=AzureOpenAI(id="o3"),
    tools=[
        YFinanceTools(
            stock_price=True,
            analyst_recommendations=True,
            company_info=True,
            company_news=True,
        )
    ],
    instructions="Use tables to display data.",
    markdown=True,
)
agent.print_response("Write a report comparing NVDA to TSLA", 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 yfinance
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