> ## 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.

# ストリーミング出力

デフォルトでは、モデルの 1 ターンの応答は完全に生成された後に 1 つの完結したメッセージとして送られます。ストリーミング出力を有効にすると、SDK は生成中に細粒度の増分チャンクを継続的に push します。タイプライター効果や、推論過程・ツール呼び出し過程を個別にレンダリングするのに使えます。

<div id="有効化" />

## 有効化

`options` で `includePartialMessages: true` を設定します：

```typescript theme={null}
import { qodercliAuth, query } from '@qoder-ai/qoder-agent-sdk';

const q = query({
  prompt: 'Write a short analysis report',
  options: {
    auth: qodercliAuth(),
    includePartialMessages: true,
  },
});
```

<div id="タイプライター効果" />

## タイプライター効果

モデルが生成するテキストは増分チャンクとして連続的に届きます。届くたびに出力すればタイプライター効果になります：

```typescript theme={null}
for await (const msg of q) {
  if (msg.type === 'stream_event') {
    const delta = msg.event.delta;
    if (delta?.type === 'text_delta') {
      process.stdout.write(delta.text);
    }
  }
}
```

<div id="推論過程" />

## 推論過程

推論モデルは正式な応答の前に「思考」チャンクを産出します：

```typescript theme={null}
if (delta?.type === 'thinking_delta') {
  process.stdout.write(delta.thinking);
}
```

<div id="ツール呼び出しの引数" />

## ツール呼び出しの引数

ツール呼び出しの引数も段階的に生成されます。例えば、モデルが書き込んでいるファイル内容を UI でリアルタイムにレンダリングするのに使えます：

```typescript theme={null}
if (delta?.type === 'input_json_delta') {
  process.stdout.write(delta.partial_json);
}
```

完全なイベント構造は [SDK References](/ja/cli/sdk/references) を参照してください。
