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

# Gemini Basic Reasoning Stream

> Stream reasoning events from Gemini 2.5 Flash with a thinking budget enabled.

```python basic_reasoning_stream.py theme={null}
"""
Basic Reasoning Stream
======================

Demonstrates this reasoning cookbook example.
"""

from agno.agent import Agent
from agno.models.google import Gemini
from agno.run.agent import RunEvent  # noqa


# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
def run_example() -> None:
    # Create an agent with reasoning enabled
    # Note: For Gemini, you MUST set thinking_budget to enable thinking mode
    agent = Agent(
        reasoning_model=Gemini(
            id="gemini-2.5-flash",
            thinking_budget=1024,  # Required to enable thinking mode
            include_thoughts=True,  # Include thought summaries in response
        ),
        reasoning=True,
        instructions="Think step by step about the problem.",
    )

    prompt = "What is 25 * 37? Show your reasoning."

    agent.print_response(prompt, stream=True, stream_events=True)

    # # Use manual event loop to see all events
    # async for run_output_event in agent.arun(
    #     prompt,
    #     stream=True,
    #     stream_events=True,
    # ):
    #     if run_output_event.event == RunEvent.run_started:
    #         print(f"\nEVENT: {run_output_event.event}")

    #     elif run_output_event.event == RunEvent.reasoning_started:
    #         print(f"\nEVENT: {run_output_event.event}")
    #         print("Reasoning started...\n")

    #     elif run_output_event.event == RunEvent.reasoning_content_delta:
    #         # This is the NEW streaming event for reasoning content
    #         print(run_output_event.reasoning_content, end="", flush=True)

    #     elif run_output_event.event == RunEvent.reasoning_step:
    #         print(f"\nEVENT: {run_output_event.event}")

    #     elif run_output_event.event == RunEvent.reasoning_completed:
    #         print(f"\n\nEVENT: {run_output_event.event}")

    #     elif run_output_event.event == RunEvent.run_content:
    #         if run_output_event.content:
    #             print(run_output_event.content, end="", flush=True)

    #     elif run_output_event.event == RunEvent.run_completed:
    #         print(f"\n\nEVENT: {run_output_event.event}")


# ---------------------------------------------------------------------------
# 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 google-genai openai
    ```
  </Step>

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

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

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

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

Full source: [cookbook/10\_reasoning/models/gemini/basic\_reasoning\_stream.py](https://github.com/agno-agi/agno/blob/main/cookbook/10_reasoning/models/gemini/basic_reasoning_stream.py)
