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

# ChatStream

> Sync context manager for SSE chat streams.

Sync context manager for SSE chat streams. Async clients use `AsyncChatStream` (same methods with `async`).

### ChatStream

```python
class ChatStream(http: HttpClient, path: str, body: Dict[str, Any])
```

Bases: `object`

Sync context manager for SSE chat streams.

Returned by `client.modus.stream(...)` / `client.scopes.stream(...)`. Iterate `text_stream` for tokens, or `event_stream` for typed events, then call `get_final_result()` for the assembled `ChatResult`.

For async clients, see `AsyncChatStream`.

#### text\_stream

```python
property text_stream: Iterator[str]
```

Yield assistant reply text as it arrives, one token at a time.

#### event\_stream

```python
property event_stream: Iterator[TokenEvent | DoneEvent | ErrorEvent | CancelledEvent | StreamTimeoutEvent | AssistantContentResetEvent]
```

Yield typed stream events (tokens, tool calls, done, errors).

#### get\_final\_result()

```python
get_final_result() → SkillChatResponseDto
```

Return the assembled reply after the stream finishes.

* Raises:

  [**ModusError**](<> "modus._exceptions.ModusError") – if called before the stream emits a done event.

### AsyncChatStream

```python
class AsyncChatStream(http: AsyncHttpClient, path: str, body: Dict[str, Any])
```

Bases: `object`

Async context manager for SSE chat streams.

Same shape as `ChatStream` for `AsyncModus` / async resource methods.

#### text\_stream

```python
property text_stream: AsyncIterator[str]
```

Yield assistant reply text as it arrives. See sync `text_stream` for details.

#### event\_stream

```python
property event_stream: AsyncIterator[TokenEvent | DoneEvent | ErrorEvent | CancelledEvent | StreamTimeoutEvent | AssistantContentResetEvent]
```

Yield typed stream events as they arrive. See sync `event_stream` for details.

#### get\_final\_result()

```python
get_final_result() → SkillChatResponseDto
```

Return the assembled reply after the stream finishes. See sync `get_final_result`.
