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

# Stream Reasoning Events over AG-UI

> Enable Agno's reasoning loop and translate its reasoning lifecycle into AG-UI REASONING_START, content, and end events before the final answer.

```python reasoning_agent.py theme={null}
"""
Stream Reasoning Events over AG-UI
==================================

Enable Agno's reasoning loop and translate its reasoning lifecycle into
AG-UI REASONING_START, content, and end events before the final answer.

Prerequisites: OPENAI_API_KEY
Run: .venvs/demo/bin/python cookbook/05_agent_os/16_agui/reasoning_agent.py
Try: POST a multi-step logic problem to http://localhost:7777/reasoning/agui
"""

from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS
from agno.os.interfaces.agui import AGUI

# ---------------------------------------------------------------------------
# Create Reasoning Agent
# ---------------------------------------------------------------------------

db = SqliteDb(
    id="agui-reasoning-db",
    db_file="tmp/agui_reasoning.db",
)

reasoning_agent = Agent(
    id="agui-reasoning-agent",
    name="AG-UI Reasoning Agent",
    model=OpenAIResponses(id="gpt-5.6"),
    db=db,
    reasoning_model=OpenAIResponses(id="o3-mini"),
    instructions="Solve the problem carefully, then give a concise final answer.",
)

agent_os = AgentOS(
    id="agui-reasoning-os",
    description="AgentOS translating Agno reasoning events to AG-UI.",
    agents=[reasoning_agent],
    interfaces=[AGUI(agent=reasoning_agent, prefix="/reasoning")],
)
app = agent_os.get_app()

# ---------------------------------------------------------------------------
# Run Reasoning Server
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    agent_os.serve(app=app)
```

## Run the Example

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

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

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

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

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

Full source: [cookbook/05\_agent\_os/16\_agui/reasoning\_agent.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/05_agent_os/16_agui/reasoning_agent.py)
