stream

open override fun stream(request: ChatRequest): Flow<ChatEvent>

Sends request to the Messages API with stream set, and returns Claude's answer as it arrives: the text piece by piece, then the whole answer. The whole answer is the one chat returns for the same request, with its tool calls, usage and provider content.

The flow fails with a ChatModelException when the API cannot be reached, when it returns an error, when the connection ends before the answer does, and when Claude declines the request. Claude can decline after it wrote a part of an answer; that part is not an answer.