Stream chat state
Real-time streaming conversation with Cube’s AI agents for analytics and data exploration.
The response is streamed as newline-delimited JSON (each line is a standalone JSON object
terminated by \n) and served with Content-Type: application/json. Each line represents a
chat message, a state update, or an error object. Assistant content arrives incrementally —
updates to a previously emitted message carry the same id with isDelta: true.
Provide input to send a new message. Omit input (with a chatId) to retrieve the current
thread state. If chatId is omitted a new thread is created and its id is returned on the
__cutoff__ message.
Special sentinel messages:
__cutoff__— initial marker emitted before new content; also carries the threadchatIdandisStreamingunderstate.__state__— final thread snapshot emitted at the end, carrying the full{ messages: [...] }state.
Errors mid-stream are emitted as a standalone line { "error": "<message>" } rather than a non-200 status.
Finding the final answer: filter assistant messages where graphPath[0] === "final" and
graphPath.length <= 2; the last such message is the final answer.
Idempotency: provide a client-generated messageId in the format <timestamp>-message (a 13+ digit
Unix-millisecond timestamp). If a request with the same messageId arrives while a stream for that
message is still active on the thread, the API resubscribes the new request to the existing stream
instead of starting a new one.
Authorizations
API key authentication. Send Authorization: Api-Key <YOUR_API_KEY>.
Body
Chat request. Provide input to send a new message, or omit it together with a chatId to retrieve the current thread state.
Development branch name to run queries against. Uses the main branch if omitted.
Chat thread ID. If omitted, a new thread is created automatically. Should match the previously returned chatId carried on the __cutoff__ message.
chat, workbook, model, dashboard, external, mcp, ai-widget, onboarding, explore, connection_setup, slack_dm, published-dashboard User's message/question. If omitted, returns the current thread state for the provided chatId.
Whether activeBranchName is the default branch. Defaults to true when not set.
Client-provided identifier in the format <timestamp>-message (13+ digit Unix milliseconds). Makes requests idempotent.
^\d{13,}-message$Response
Newline-delimited stream of chat message / state / error objects (served as Content-Type: application/json). Each line is a JSON object of the schema below.
Message content. Streamed incrementally for assistant messages when isDelta is true.
Present only on error lines ({ "error": "<message>" }). When set, the line carries no message fields.
Agent graph node path, e.g. ["cube_data_analyst_agent"] or ["final"].
Unique message identifier. Sentinel values: __cutoff__ (initial marker, carries the chatId under state) and __state__ (final thread state snapshot). Absent on error lines.
Whether this is an incremental update to a previously sent message with the same id.
Whether the message is still being generated.
user, assistant Message ordering sequence.
Streaming state. Carries { isStreaming, chatId } on the __cutoff__ message and { messages: [...] } on the __state__ message.
Agent's internal reasoning. Only present in development mode.
Present when the message represents a tool invocation or its result.