Chat Verbosity Control
Control response length with the gpt-5 verbosity parameter in a finance report agent.
"""
Openai Verbosity Control
========================
Cookbook example for `openai/chat/verbosity_control.py`.
"""
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.yfinance import YFinanceTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=OpenAIChat(id="gpt-5", verbosity="high"),
tools=[YFinanceTools()],
instructions="Use tables to display data.",
markdown=True,
)
agent.print_response("Write a report comparing NVDA to 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 verbosity_control.py, then run:
python verbosity_control.pyFull source: cookbook/90_models/openai/chat/verbosity_control.py