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.

tool_use_o3.py
"""
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__":
    pass

Run the Example

Set up your virtual environment

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

Install dependencies

uv pip install -U agno openai yfinance

Export 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.py

Full source: cookbook/90_models/openai/responses/tool_use_o3.py