reasoning_agent.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export your LiteLLM API key
4
Run the example
Save the code above as
reasoning_agent.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 DeepSeek R1 reasoning_content through LiteLLM while the agent compares 9.11 and 9.9.
"""
LiteLLM Reasoning Agent Example
This example demonstrates using reasoning models through LiteLLM.
The reasoning_content from the model response is extracted and displayed.
Supported reasoning models through LiteLLM:
- deepseek/deepseek-reasoner (DeepSeek R1)
"""
from agno.agent import Agent
from agno.models.litellm import LiteLLM
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
task = "9.11 and 9.9 -- which is bigger?"
# Using DeepSeek R1 through LiteLLM
agent = Agent(
model=LiteLLM(
id="deepseek/deepseek-reasoner",
),
markdown=True,
)
agent.print_response(task, stream=True, stream_events=True, show_reasoning=True)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
pass
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 litellm
Export your LiteLLM API key
export LITELLM_API_KEY="your_litellm_api_key_here"
$Env:LITELLM_API_KEY="your_litellm_api_key_here"
Run the example
reasoning_agent.py, then run:python reasoning_agent.py
Was this page helpful?