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

# Streaming

> Stream ReyGrid chat replies in Python with stream_chat and async_stream_chat.

`stream_chat()` (sync generator) and `async_stream_chat()` (async generator) send the chat request with `stream: true` and yield one `ChatDeltaEvent` per SSE frame.

```python theme={"system"}
for frame in client.stream_chat("{AgentId}", "What are your hours?", user_id="user-42"):
    if frame.delta and frame.delta.reply and frame.delta.reply.content:
        print(frame.delta.reply.content, end="", flush=True)
```

```python theme={"system"}
async for frame in client.async_stream_chat("{AgentId}", "Tell me about the Pro plan"):
    if frame.delta and frame.delta.reply and frame.delta.reply.content:
        print(frame.delta.reply.content, end="", flush=True)
```

## Signature

```python theme={"system"}
stream_chat(agent_id, message, *, conversation_id=None, user_id=None, tools=None, results=None)
```

Parameters match [`chat()`](/integrations/python/usage#chat).

## `ChatDeltaEvent`

| Field | Type | Description |
| - | - | - |
| `delta.reply.content` | `str \| None` | Text fragment |
| `delta.finish_reason` | `str \| None` | Set on the final frame |
| `delta.tool_calls` | `list \| None` | Tool-call deltas |
| `success`, `conversationId`, `messageId` | optional | Present on some frames |
| `usage` | `dict \| None` | Raw usage payload, e.g. `{"credits": 1}` |
| `raw` | `dict` | The unparsed frame |

## Collect the full text

```python theme={"system"}
text = "".join(
    f.delta.reply.content
    for f in client.stream_chat("{AgentId}", "Hello!")
    if f.delta and f.delta.reply and f.delta.reply.content
)
```

## Errors

* HTTP errors before the stream starts raise the usual typed exceptions (for example `ReyGridAuthError`).
* A frame that isn't valid JSON raises `ReyGridStreamError`.
* Timeouts and connection failures raise `ReyGridNetworkError`.

See [Error handling](/integrations/python/error-handling).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.