Tool Use Stream
Run a gpt-4o agent with WebSearchTools through the OpenAI Responses API and stream the response.
Code
"""Run `uv pip install ddgs` to install dependencies."""
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.websearch import WebSearchTools
agent = Agent(
model=OpenAIResponses(id="gpt-4o"),
tools=[WebSearchTools()],
markdown=True,
)
agent.print_response("Whats happening in France?", stream=True)
Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateSet your API key
export OPENAI_API_KEY=xxxInstall dependencies
uv pip install -U openai ddgs agnoRun Agent
Save the code above as tool_use.py, then run:
python tool_use.py