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

# Streaming Output

By default, a model's reply is delivered as a single complete message at the end of each turn. With streaming output enabled, the SDK pushes fine-grained incremental chunks as the model generates them — useful for typewriter effects, or for rendering reasoning and tool-invocation progress separately.

<div id="enable" />

## Enable

Set `include_partial_messages=True` in `QoderAgentOptions`:

```python theme={null}
from qoder_agent_sdk import QoderAgentOptions, access_token_from_env, query

options = QoderAgentOptions(
    auth=access_token_from_env(),
    include_partial_messages=True,
)

async for msg in query(prompt="Write a short analysis report", options=options):
    ...
```

<div id="typewriter-effect" />

<div id="typewritereffect" />

## Typewriter effect

The model's text reply arrives as a sequence of incremental chunks; printing each chunk as it lands gives a typewriter effect:

```python theme={null}
import sys

from qoder_agent_sdk import StreamEvent


async for msg in query(prompt="...", options=options):
    if isinstance(msg, StreamEvent):
        delta = msg.event.get("delta")
        if delta and delta.get("type") == "text_delta":
            sys.stdout.write(delta["text"])
            sys.stdout.flush()
```

<div id="reasoning" />

## Reasoning

Reasoning-capable models emit "thinking" chunks before their final reply:

```python theme={null}
if isinstance(msg, StreamEvent):
    delta = msg.event.get("delta")
    if delta and delta.get("type") == "thinking_delta":
        sys.stdout.write(delta["thinking"])
        sys.stdout.flush()
```

<div id="tool-invocation-arguments" />

<div id="toolinvocationarguments" />

## Tool invocation arguments

Tool-call arguments are also generated incrementally — for example, you can use this to render the file content the model is writing in real time in your UI:

```python theme={null}
if isinstance(msg, StreamEvent):
    delta = msg.event.get("delta")
    if delta and delta.get("type") == "input_json_delta":
        sys.stdout.write(delta["partial_json"])
        sys.stdout.flush()
```

For the full event structure, see [SDK References](/en/cli/sdk/python/references#streamevent).
