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

How messages are split

  • 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

Keeping the array in a ref and copying it into state is what avoids re-running the effect that owns the conversation.

ChatMessage

Context length

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

Persisting

Conversations are plain values, so AsyncStorage works. Persist the array, not SDK state: models reload from disk on the next launch, and history is all you need to carry.