Skip to main content
POST
Stream chat state

Authorizations

Authorization
string
header
required

API key authentication. Send Authorization: Api-Key <YOUR_API_KEY>.

Body

application/json

Chat request. Provide input to send a new message, or omit it together with a chatId to retrieve the current thread state.

activeBranchName
string

Development branch name to run queries against. Uses the main branch if omitted.

chatId
string

Chat thread ID. If omitted, a new thread is created automatically. Should match the previously returned chatId carried on the __cutoff__ message.

images
object[]
input
string

User's message/question. If omitted, returns the current thread state for the provided chatId.

isDefaultBranch
boolean

Whether activeBranchName is the default branch. Defaults to true when not set.

messageId
string

Client-provided identifier in the format <timestamp>-message (13+ digit Unix milliseconds). Makes requests idempotent.

Pattern: ^\d{13,}-message$
sessionSettings
object

Response

Newline-delimited stream of chat message / state / usage / error objects (served as Content-Type: application/json). Each line is a JSON object of the schema below.

code
enum<string>

Machine-readable reason the run ended early. Present only on the __aborted__ and __suspended__ frames.

Available options:
chat_aborted,
chat_suspended
content
string

Message content. Streamed incrementally for assistant messages when isDelta is true.

error
string

Present on error lines ({ "error": "<message>" }), which carry no message fields, and on the __aborted__ and __suspended__ frames.

graphPath
string[]

Agent graph node path, e.g. ["cube_data_analyst_agent"] or ["final"].

id
string

Unique message identifier. Sentinel values: __cutoff__ (initial marker, carries the chatId under state), __state__ (thread state snapshot), __aborted__ (run stopped via the abort endpoint), __suspended__ (run suspended by a server restart; resend to resume), and __usage__ (always the last frame, carries model/token counts under usage). Absent on error lines.

isDelta
boolean

Whether this is an incremental update to a previously sent message with the same id.

isInProcess
boolean

Whether the message is still being generated.

messageId
string

Present only on the __suspended__ frame: the messageId of the suspended turn, to resend.

retryable
boolean

Present only on the __suspended__ frame, always true: resending the same request resumes the run.

role
enum<string>

Absent on error lines and on the __usage__ frame.

Available options:
user,
assistant
sort
number

Message ordering sequence. Absent on the __usage__ frame.

state
object

Streaming state. Carries { isStreaming, chatId } (plus suspended.messageId when a suspended turn is pending) on the __cutoff__ message and { messages: [...] } on the __state__ message.

thinking
string

Agent's internal reasoning. Only present in development mode.

toolCall
object

Present when the message represents a tool invocation or its result.

type
enum<string>

Present only on a terminal sentinel: abort on __aborted__, suspend on __suspended__, usage on __usage__. Absent on every other message.

Available options:
abort,
suspend,
usage
usage
object

Model and token counts for the run. Present only on the __usage__ frame.