OpenAI Reasoning Model GPT 4 1
Adapt the archived GPT-4.1 stage to a supported separate OpenAI reasoning model.
"""
Reasoning Model Gpt 4 1
=======================
Demonstrates this reasoning cookbook example.
"""
from agno.agent import Agent
from agno.models.openai.responses import OpenAIResponses
# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
def run_example() -> None:
agent = Agent(
model=OpenAIResponses(id="gpt-5.6-luna"),
reasoning_model=OpenAIResponses(id="gpt-4.1"),
)
agent.print_response(
"Solve the trolley problem. Evaluate multiple ethical frameworks. "
"Include an ASCII diagram of your solution.",
stream=True,
)
# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
run_example()Use a supported reasoning model
The archived OpenAIResponses(id="gpt-4.1") is not recognized as a native reasoning model, so Agno skips that stage and can still return the main model's answer. Before running, replace only the reasoning_model value with:
OpenAIResponses(id="gpt-5.2")Keep the final model and prompt unchanged.
An explicit reasoning_model runs as a separate, tool-free reasoning stage before the main model response. show_full_reasoning=True displays the reasoning data Agno receives; it cannot reveal a provider's private internal trace. Some adapters use the reasoning stage's answer text when separate reasoning content is unavailable. A failed reasoning stage can still be followed by a main-model answer, so a completed run alone does not prove the reasoning stage succeeded.
Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openaiExport your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"Run the example
Save the code above as reasoning_model_gpt_4_1.py, then run:
python reasoning_model_gpt_4_1.pyFull source: cookbook/10_reasoning/models/openai/reasoning_model_gpt_4_1.py