Skip to main content
Pass [ChatMessage] instead of a prompt to hold a conversation.

How messages are split

The SDK does not send the array verbatim. It splits it:
  • System turns become options.systemPrompt.
  • The trailing user turn becomes the prompt.
  • Everything between travels as history.
A conversation with no user turn throws SDKException.

Streaming a conversation

Keeping a transcript

ChatMessage

Context length

A conversation grows until it exceeds the model’s context window. Trim old turns yourself, keeping the system message: