Skip to article
CogniTech.Docs

Response streaming

Event framing, rendering, terminal states, and interruption handling.

On this page

Wire format

The chat messages endpoint returns application/x-ndjson for a new streaming turn. Each line is one JSON object. Transport chunks may split a line or contain several lines. The browser decodes bytes incrementally, retains incomplete lines, and validates each complete event before dispatch.

json
{"type":"start","id":"9da52e9c-b62e-4a1f-8a45-de83f030aff3"}
{"type":"delta","text":"A commitment identifies a note without exposing its secret."}
{"type":"loading","section":"market","active":false}
{"type":"done","actionId":null}

Event meanings

TypeMeaning
startIdentifies the assistant reply being streamed
delta / textAppends incremental text or sets the current assembled text
research / sourcesUpdates tool activity or available numbered source evidence
loading / blockUpdates local loading state or appends a validated rich response
actionSupplies local action-card metadata
done / errorTerminates with an optional action ID or a safe error and interruption flag

These are application events; they differ from the Anthropic SDK event shape. An unsupported or invalid block can be discarded independently. The reader rejects oversized events or a stream that closes without a terminal event. A browser cancellation propagates an abort signal. The saved reply is the recovery path after interruption.

See Claude Messages streaming, Rich Responses, and the API reference.