curl --request POST \
--url https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"activeBranchName": "<string>",
"chatId": "<string>",
"images": [
{
"data": "<string>",
"mimeType": "<string>",
"name": "<string>"
}
],
"input": "<string>",
"isDefaultBranch": true,
"messageId": "<string>",
"sessionSettings": {
"email": "<string>",
"externalId": "<string>",
"groups": [
"<string>"
],
"internalId": "<string>",
"publicDashboardId": "<string>",
"roles": [
"<string>"
],
"securityContext": {},
"userAttributes": [
"<unknown>"
]
}
}
'import requests
url = "https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state"
payload = {
"activeBranchName": "<string>",
"chatId": "<string>",
"images": [
{
"data": "<string>",
"mimeType": "<string>",
"name": "<string>"
}
],
"input": "<string>",
"isDefaultBranch": True,
"messageId": "<string>",
"sessionSettings": {
"email": "<string>",
"externalId": "<string>",
"groups": ["<string>"],
"internalId": "<string>",
"publicDashboardId": "<string>",
"roles": ["<string>"],
"securityContext": {},
"userAttributes": ["<unknown>"]
}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
activeBranchName: '<string>',
chatId: '<string>',
images: [{data: '<string>', mimeType: '<string>', name: '<string>'}],
input: '<string>',
isDefaultBranch: true,
messageId: '<string>',
sessionSettings: {
email: '<string>',
externalId: '<string>',
groups: ['<string>'],
internalId: '<string>',
publicDashboardId: '<string>',
roles: ['<string>'],
securityContext: {},
userAttributes: ['<unknown>']
}
})
};
fetch('https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'activeBranchName' => '<string>',
'chatId' => '<string>',
'images' => [
[
'data' => '<string>',
'mimeType' => '<string>',
'name' => '<string>'
]
],
'input' => '<string>',
'isDefaultBranch' => true,
'messageId' => '<string>',
'sessionSettings' => [
'email' => '<string>',
'externalId' => '<string>',
'groups' => [
'<string>'
],
'internalId' => '<string>',
'publicDashboardId' => '<string>',
'roles' => [
'<string>'
],
'securityContext' => [
],
'userAttributes' => [
'<unknown>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state"
payload := strings.NewReader("{\n \"activeBranchName\": \"<string>\",\n \"chatId\": \"<string>\",\n \"images\": [\n {\n \"data\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"input\": \"<string>\",\n \"isDefaultBranch\": true,\n \"messageId\": \"<string>\",\n \"sessionSettings\": {\n \"email\": \"<string>\",\n \"externalId\": \"<string>\",\n \"groups\": [\n \"<string>\"\n ],\n \"internalId\": \"<string>\",\n \"publicDashboardId\": \"<string>\",\n \"roles\": [\n \"<string>\"\n ],\n \"securityContext\": {},\n \"userAttributes\": [\n \"<unknown>\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"activeBranchName\": \"<string>\",\n \"chatId\": \"<string>\",\n \"images\": [\n {\n \"data\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"input\": \"<string>\",\n \"isDefaultBranch\": true,\n \"messageId\": \"<string>\",\n \"sessionSettings\": {\n \"email\": \"<string>\",\n \"externalId\": \"<string>\",\n \"groups\": [\n \"<string>\"\n ],\n \"internalId\": \"<string>\",\n \"publicDashboardId\": \"<string>\",\n \"roles\": [\n \"<string>\"\n ],\n \"securityContext\": {},\n \"userAttributes\": [\n \"<unknown>\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"activeBranchName\": \"<string>\",\n \"chatId\": \"<string>\",\n \"images\": [\n {\n \"data\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"input\": \"<string>\",\n \"isDefaultBranch\": true,\n \"messageId\": \"<string>\",\n \"sessionSettings\": {\n \"email\": \"<string>\",\n \"externalId\": \"<string>\",\n \"groups\": [\n \"<string>\"\n ],\n \"internalId\": \"<string>\",\n \"publicDashboardId\": \"<string>\",\n \"roles\": [\n \"<string>\"\n ],\n \"securityContext\": {},\n \"userAttributes\": [\n \"<unknown>\"\n ]\n }\n}"
response = http.request(request)
puts response.read_bodyStream 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.
curl --request POST \
--url https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"activeBranchName": "<string>",
"chatId": "<string>",
"images": [
{
"data": "<string>",
"mimeType": "<string>",
"name": "<string>"
}
],
"input": "<string>",
"isDefaultBranch": true,
"messageId": "<string>",
"sessionSettings": {
"email": "<string>",
"externalId": "<string>",
"groups": [
"<string>"
],
"internalId": "<string>",
"publicDashboardId": "<string>",
"roles": [
"<string>"
],
"securityContext": {},
"userAttributes": [
"<unknown>"
]
}
}
'import requests
url = "https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state"
payload = {
"activeBranchName": "<string>",
"chatId": "<string>",
"images": [
{
"data": "<string>",
"mimeType": "<string>",
"name": "<string>"
}
],
"input": "<string>",
"isDefaultBranch": True,
"messageId": "<string>",
"sessionSettings": {
"email": "<string>",
"externalId": "<string>",
"groups": ["<string>"],
"internalId": "<string>",
"publicDashboardId": "<string>",
"roles": ["<string>"],
"securityContext": {},
"userAttributes": ["<unknown>"]
}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
activeBranchName: '<string>',
chatId: '<string>',
images: [{data: '<string>', mimeType: '<string>', name: '<string>'}],
input: '<string>',
isDefaultBranch: true,
messageId: '<string>',
sessionSettings: {
email: '<string>',
externalId: '<string>',
groups: ['<string>'],
internalId: '<string>',
publicDashboardId: '<string>',
roles: ['<string>'],
securityContext: {},
userAttributes: ['<unknown>']
}
})
};
fetch('https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'activeBranchName' => '<string>',
'chatId' => '<string>',
'images' => [
[
'data' => '<string>',
'mimeType' => '<string>',
'name' => '<string>'
]
],
'input' => '<string>',
'isDefaultBranch' => true,
'messageId' => '<string>',
'sessionSettings' => [
'email' => '<string>',
'externalId' => '<string>',
'groups' => [
'<string>'
],
'internalId' => '<string>',
'publicDashboardId' => '<string>',
'roles' => [
'<string>'
],
'securityContext' => [
],
'userAttributes' => [
'<unknown>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state"
payload := strings.NewReader("{\n \"activeBranchName\": \"<string>\",\n \"chatId\": \"<string>\",\n \"images\": [\n {\n \"data\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"input\": \"<string>\",\n \"isDefaultBranch\": true,\n \"messageId\": \"<string>\",\n \"sessionSettings\": {\n \"email\": \"<string>\",\n \"externalId\": \"<string>\",\n \"groups\": [\n \"<string>\"\n ],\n \"internalId\": \"<string>\",\n \"publicDashboardId\": \"<string>\",\n \"roles\": [\n \"<string>\"\n ],\n \"securityContext\": {},\n \"userAttributes\": [\n \"<unknown>\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"activeBranchName\": \"<string>\",\n \"chatId\": \"<string>\",\n \"images\": [\n {\n \"data\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"input\": \"<string>\",\n \"isDefaultBranch\": true,\n \"messageId\": \"<string>\",\n \"sessionSettings\": {\n \"email\": \"<string>\",\n \"externalId\": \"<string>\",\n \"groups\": [\n \"<string>\"\n ],\n \"internalId\": \"<string>\",\n \"publicDashboardId\": \"<string>\",\n \"roles\": [\n \"<string>\"\n ],\n \"securityContext\": {},\n \"userAttributes\": [\n \"<unknown>\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}/chat/stream-chat-state")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"activeBranchName\": \"<string>\",\n \"chatId\": \"<string>\",\n \"images\": [\n {\n \"data\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"input\": \"<string>\",\n \"isDefaultBranch\": true,\n \"messageId\": \"<string>\",\n \"sessionSettings\": {\n \"email\": \"<string>\",\n \"externalId\": \"<string>\",\n \"groups\": [\n \"<string>\"\n ],\n \"internalId\": \"<string>\",\n \"publicDashboardId\": \"<string>\",\n \"roles\": [\n \"<string>\"\n ],\n \"securityContext\": {},\n \"userAttributes\": [\n \"<unknown>\"\n ]\n }\n}"
response = http.request(request)
puts response.read_bodyAuthorizations
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.
Show child attributes
Show child attributes
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$Show child attributes
Show child attributes
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.
Show child attributes
Show child attributes