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

Persisting across launches

A desktop app is expected to remember. Conversations are plain values, so writing them as JSON under the app’s user-data directory is enough. Persist the array, not SDK state: models reload from disk on the next launch, and history is all you need to carry.

Context length

Trim before the conversation outgrows the model’s window, keeping the system message:
A desktop can afford a larger contextLength at load time, which pushes this problem further out but does not remove it.