OpenAI Tool Use O3
Fetch stock quotes through the Responses API with cached YFinance tool results.
cache_results=True reuses matching tool results for the default one-hour cache TTL. Repeated calls can return a prior quote. Change the toolkit to YFinanceTools(cache_results=False) to fetch again; the data provider still determines the quote timestamp and any market-data delay.
"""
Openai Tool Use O3
==================
Cookbook example for `openai/responses/tool_use_o3.py`.
"""
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.yfinance import YFinanceTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=OpenAIResponses(id="o3"),
tools=[YFinanceTools(cache_results=True)],
markdown=True,
telemetry=False,
)
agent.print_response("What is the current price of TSLA?", stream=True)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
passRun the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openai yfinanceExport your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"Run the example
Save the code above as tool_use_o3.py, then run:
python tool_use_o3.pyFull source: cookbook/90_models/openai/responses/tool_use_o3.py