Agent with Tools

Give an AzureOpenAI agent web search with WebSearchTools.

Code

from agno.agent import Agent
from agno.models.azure import AzureOpenAI
from agno.tools.websearch import WebSearchTools

agent = Agent(
    model=AzureOpenAI(id="gpt-4o-mini"),
    tools=[WebSearchTools()],
    markdown=True,
)

agent.print_response("Whats happening in France?", stream=True)

Usage

Create or select a gpt-4o-mini chat deployment. Set AZURE_OPENAI_DEPLOYMENT to its actual deployment name, and use the key and resource endpoint for that deployment. You may omit the deployment setting only when an existing deployment is named exactly like id. Keep id aligned with the deployed model family.

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Set your API key

export AZURE_OPENAI_API_KEY=xxx
export AZURE_OPENAI_ENDPOINT=xxx
export AZURE_OPENAI_DEPLOYMENT="your_chat_deployment"

Install dependencies

uv pip install -U openai ddgs agno

Run Agent

Save the code above as tool_use.py, then run:

python tool_use.py