Async Tool Use
Run a gpt-4o agent with WebSearchTools asynchronously and stream the response through the OpenAI Responses API.
Code
"""Run `uv pip install ddgs` to install dependencies."""
import asyncio
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,
)
asyncio.run(agent.aprint_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
python async_tool_use.py