Skip to main content
Pass an array of messages instead of a string. Same method.

How messages are split

The array is not sent verbatim:
  • System turns become options.systemPrompt.
  • The trailing user turn becomes the prompt.
  • Everything between travels as history.
A conversation with no user turn throws.

Streaming a conversation

Keeping a transcript

ChatMessage

Context length

Trim before the conversation outgrows the model’s window, keeping the system message:

Persisting across reloads

Conversations are ordinary values, so IndexedDB or localStorage both work. Persist the array, not the SDK state: models reload from disk on the next visit, and history is all you need to carry.