---
title: "client.chat"
description: "Stream a chat conversation with an agent or swarm.
Returns an async generator of SSE events."
section: "Libraries"
group: "SDK resources"
order: 202
---

Accessed via `client.chat`.

## Methods

### `chat`

Stream a chat conversation with an agent or swarm.
Returns an async generator of SSE events.

```ts
async chat(id: string, body: { messages: unknown[] }): Promise<AsyncGenerator<SSEEvent>>
```

```ts
const stream = await client.chat("agt_abc123", {
  messages: [{ role: "user", content: "Hello" }],
});
for await (const event of stream) {
  console.log(event.data);
}
```
