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

# Conversation

> Stateful multi-turn helper that manages message history automatically.

`Conversation` is created via `client.conversation()` and manages a growing message array across turns.

## Constructor

```ts theme={null}
client.conversation(options: ConversationOptions): Conversation
```

Via `GatelitClient.conversation()`:

```ts theme={null}
const conv = client.conversation({
  model: "openai/gpt-4o",
  systemPrompt: "You are a helpful assistant.",
  maxTokens: 500,
  temperature: 0.7,
})
```

### `ConversationOptions`

| Field          | Type     | Required | Description                                         |
| -------------- | -------- | -------- | --------------------------------------------------- |
| `model`        | `string` | Yes      | Model in `provider/model` format                    |
| `systemPrompt` | `string` | No       | Prepended to every request (not part of `messages`) |
| `maxTokens`    | `number` | No       | Default max tokens per turn                         |
| `temperature`  | `number` | No       | Default temperature per turn                        |

## Properties

### `messages`

```ts theme={null}
readonly messages: ChatMessage[]
```

The full conversation history. Starts empty and grows with each `send()` and `stream()` call. Includes both user and assistant messages.

## Methods

### `send(content, signal?)`

```ts theme={null}
send(content: string, signal?: AbortSignal): Promise<ChatResponse>
```

Sends a user message and waits for the full assistant response. Both messages are appended to `messages`.

```ts theme={null}
const conv = client.conversation({ model: "openai/gpt-4o" })
const r1 = await conv.send("Hello")
// conv.messages.length === 2 (user + assistant)
```

### `stream(content, signal?)`

```ts theme={null}
stream(content: string, signal?: AbortSignal): AsyncGenerator<StreamChunk>
```

Same as `send()` but streams the response. The assistant message is appended to `messages` after the stream completes.

```ts theme={null}
const conv = client.conversation({ model: "anthropic/claude-3-5-haiku-20241022" })

for await (const chunk of conv.stream("Tell me a joke")) {
  process.stdout.write(chunk.delta)
}
// conv.messages now includes both turns
```

### `reset()`

```ts theme={null}
reset(): void
```

Clears the message history.

```ts theme={null}
conv.reset()
// conv.messages === []
```
