Azure OpenAI Reasoning Model GPT 4 1
Adapt the archived GPT-4.1 stage to a native Azure OpenAI reasoning deployment.
"""
Reasoning Model Gpt 4 1
=======================
Demonstrates this reasoning cookbook example.
"""
from agno.agent import Agent
from agno.models.azure.openai_chat import AzureOpenAI
# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
def run_example() -> None:
agent = Agent(
model=AzureOpenAI(id="gpt-5.6-luna"), reasoning_model=AzureOpenAI(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()Select a native reasoning deployment
The archived AzureOpenAI(id="gpt-4.1") is not recognized as a native reasoning model. Agno can skip that stage and still produce a final answer. Deploy GPT-5.2 in your Azure resource, then replace the reasoning_model value with:
AzureOpenAI(id="gpt-5.2", azure_deployment="your-reasoning-deployment")Replace the deployment placeholder with the name from your resource. Keep the underlying model ID in id so Agno can recognize its reasoning capability. AZURE_OPENAI_API_KEY and AZURE_OPENAI_ENDPOINT identify the resource; they do not create the deployment.
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.
Also deploy the final GPT-5.6 Luna model and replace its constructor with AzureOpenAI(id="gpt-5.6-luna", azure_deployment="your-answer-deployment"). Use explicit per-model deployment names so the two calls cannot accidentally share one AZURE_OPENAI_DEPLOYMENT setting.
Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openaiExport environment variables
export AZURE_OPENAI_API_KEY="your_azure_openai_api_key_here"
export AZURE_OPENAI_ENDPOINT="your_azure_openai_endpoint_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/azure_openai/reasoning_model_gpt_4_1.py