> ## Documentation Index
> Fetch the complete documentation index at: https://phidatainc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Azure OpenAI Reasoning Model GPT 4 1

> Delegate reasoning to GPT-4.1 while GPT-4o-mini writes the answer, both on Azure OpenAI.

```python reasoning_model_gpt_4_1.py theme={null}
"""
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-4o-mini"), 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()
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export environment variables">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export AZURE_OPENAI_API_KEY="your_azure_openai_api_key_here"
      export AZURE_OPENAI_ENDPOINT="your_azure_openai_endpoint_here"
      ```

      ```bash Windows theme={null}
      $Env:AZURE_OPENAI_API_KEY="your_azure_openai_api_key_here"
      $Env:AZURE_OPENAI_ENDPOINT="your_azure_openai_endpoint_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `reasoning_model_gpt_4_1.py`, then run:

    ```bash theme={null}
    python reasoning_model_gpt_4_1.py
    ```
  </Step>
</Steps>

Full source: [cookbook/10\_reasoning/models/azure\_openai/reasoning\_model\_gpt\_4\_1.py](https://github.com/agno-agi/agno/blob/main/cookbook/10_reasoning/models/azure_openai/reasoning_model_gpt_4_1.py)
