reasoning_model.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export your API keys
4
Run the example
Save the code above as
reasoning_model.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Stream a Claude thinking-model chain of thought live from an AgentOS reasoning agent.
"""
Example showing a reasoning Agent in the AgentOS.
You can interact with the Agent as normally. It will reason before providing a final answer.
You will see its chain of thought live as it is generated.
"""
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.os import AgentOS
from agno.run.agent import RunEvent # noqa
# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
# Create an agent with reasoning enabled
agent = Agent(
reasoning_model=Claude(
id="claude-sonnet-4-5",
thinking={"type": "enabled", "budget_tokens": 1024},
),
reasoning=True,
instructions="Think step by step about the problem.",
)
# Setup our AgentOS app
agent_os = AgentOS(
description="Reasoning model streaming",
agents=[agent],
)
app = agent_os.get_app()
# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
"""Run your AgentOS.
You can see the configuration and available apps at:
http://localhost:7777/config
"""
agent_os.serve(app="reasoning_model:app", reload=True)
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U "agno[os]" anthropic openai
Export your API keys
export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:ANTHROPIC_API_KEY="your_anthropic_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
Run the example
reasoning_model.py, then run:python reasoning_model.py
Was this page helpful?