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

> Streaming chat session.

Streaming chat session. Iterate `ChatStream.textStream` or
`ChatStream.eventStream`, then call `ChatStream.getFinalResult`.

## Constructor

```typescript
ChatStream(http: HttpClient, path: string, body: Record<string, unknown>, baseUrl?: string): ChatStream
```

### Parameters

<ResponseField name={"http"} type={"HttpClient"} required />

<ResponseField name={"path"} type={"string"} required />

<ResponseField name={"body"} type={"Record<string, unknown>"} required />

<ResponseField name={"baseUrl"} type={"string"} />

### Returns

`ChatStream`

## Methods

### eventStream()

```typescript
eventStream(): AsyncGenerator<RunEvent>
```

Async iterable of structured run events (tokens, tool calls, done, and so on).

#### Returns

`AsyncGenerator<RunEvent>`

An async generator yielding `RunEvent` objects.

### getFinalResult()

```typescript
getFinalResult(): ChatResult
```

Final chat result after the stream completes.

Call only after fully consuming `ChatStream.textStream` or
`ChatStream.eventStream`.

#### Returns

`ChatResult`

The assembled assistant reply, thread id, and run id.

### textStream()

```typescript
textStream(): AsyncGenerator<string>
```

Async iterable of assistant text token chunks as they arrive.

#### Returns

`AsyncGenerator<string>`

An async generator yielding partial text strings.
