You need to enable JavaScript to run this app.
DataAgent (OnPremise)

DataAgent (OnPremise)

Copy page
Download PDF
Session
Session Completion
Copy page
Download PDF
Session Completion

You can use the chat completion API to obtain real-time results during the querying process. The chat completion API is a streaming interface; the event stream outputs [DONE] or the termination of the response stream indicates completion.

Precautions

This API currently does not support multi-turn conversations.

Request description
  • Request method: POST
  • Request URL: /dataAgent/llm/openApi/v2/signed/agent/chatCompletion
  • Content-Type:text/event-stream

Request parameters

The body parameters are as follows.

Parameter

Type

Required

Example value

Description

sessionId

int

Yes

12886164

Session ID. Enter the data.sessionInfo.id returned by createSession above.

type

string

Yes

query

Enter "query" as a fixed value.

source

string

Yes

openapi

Request source. Enter the fixed value "openapi".

data

object

Yes

See the request example below

Details of the chat completion session.

data.userInput

string

Yes

See the request example below

The question for intelligent query.

data.enableClarify

boolean

No

true

Indicates whether to enable clarification by counter-questioning. Clarification by counter-questioning is enabled only when this value is true and the clarification switch is enabled in the agent management console.

data.enable_report_search

boolean

No

true

Indicates whether to enable chart search. Chart search is enabled only when this value is true and a chart-type data source is configured in the agent management console.

data.clarifyResults

object

No

See the request example below

Intent clarification result. When the previous session result is returned in the format of message number 11, fill in this field to indicate the user's selection during the intent clarification interaction.

data.clarifyResults.toolCallId

string

Yes

See the request example below

Fill in the toolCallId from the event in the previous session result.

data.clarifyResults.skipClarify

boolean

No

false

Indicates whether to skip clarification by counter-questioning and let the model decide. Default is false.

data.clarifyResults.userChoices

array

Yes

Refer to the request example below

Selection of clarification content for ambiguous questions.

data.clarifyResults.userChoices[].type

string

Yes

Refer to the request example below

Just fill back the result.suggestions[].type field in event.

data.clarifyResults.userChoices[].options

array

Yes

Refer to the request example below

Just fill back the information from result.suggestions[].options in event based on the user's selection.

data.clarifyResults.userChoices[].description

string

Yes

Refer to the request example below

Just fill back the result.suggestions[].description field in event.

Request example
{
    "sessionId": 12886164,
    "type": "query",
    "data": {
        "userInput": "在超市数据集中,有哪些带“北”字的城市",
        "enableClarify": true,
        "enable_report_search": true,
        "clarifyResults": { // The initial question count can be empty.
            "toolCallId": "",
            "skipClarify": false,
            "userChoices": [
                {
                    "type": "",
                    "options": [
                        {
                            "tableName": "",
                            "tableId": int,
                            "fieldName": "",
                            "value": "",
                            "appId": int,
                        }
                    ],
                    "description": ""
                }
            ]
        }
    }
}

Response parameters

The response (text/event-stream) from this API follows the SSE protocol. For details about the SSE protocol, refer to SSE protocol description (external link). The returned result is a message prefixed with data:. The parameters contain key message results of the streaming output. Details about data are as follows.

data

Detailed description of the returned data is as follows.

tip

The core parameters contained in the data response message are as follows:

  • type: The type parameter is used to determine the type of the current response message.
    • For example, init (session initialization), result (model returned result), and so on.
    • The currently supported type enumeration values can be found in Enumeration values for type below.
  • status: Messages of the same type may include multiple stages in the question flow. The status parameter is used to indicate the stage of messages of the same type.
    • For example, when type=result, it means the returned message is the model's result; status=success indicates that the model's result is a successful query.
    • The currently supported status enumeration values can be found in Enumeration values for status below.

The current data message types and examples are described as follows.

Serial number

Sample message format

Key parameter description

1

{"type":"init","query_type":"normal","sub_query_info":[{"question": ${user_input} }],"is_thought_mode":true}

  • type value: init
  • Message meaning: Session initialization message

2

{"sub_id":0,"type":"result","status":"failed","msg":"Error message","result":{}}

  • type value: result
  • status:field
  • Message meaning: Error message

3

{"round_id": 0, "sub_id": 0, "is_major": true, "type": "thought", "content": "Starting chart search......\n\n"}

  • type value: thought
  • Message meaning: Model thinking information message

4

{"round_id": 1, "sub_id": 0, "is_major": true, "type": "code", "content": "Based on"}

  • type value: code
  • Message meaning: Model output message, can be ignored.

5

{"round_id": 2, "sub_id": 0, "is_major": false, "type": "tool", "content": "Preparing to call tool: (round_id=2, sub_id=0)function::ansi_sql_execution,id::call_dw4nr47544y4itglz76up2n1"}

  • type value: tool
  • Message meaning: Tool invocation process information

6

{"type": "debug", "content": "voting_result: all_full_equals True, major_index 1, diverge_index_list[], similar_index_list[]"}

  • type value: debug
  • Message meaning: Debug information for multi-round or parallel invocation, can be ignored

7

{"round_id": 0, "sub_id": 0, "is_major": true, "type": "exec_context", "content": "-- SQL generated by the model \n SELECT DISTINCT 城市 \n FROM 4250665 \n WHERE 城市 LIKE '%北%' ;"}

  • type value: exec_context
  • Message meaning: Context information output during tool execution

8

{"round_id": 0, "sub_id": 0, "is_major": true, "type": "exec_result", "content": "Tool invocation execution result"}

  • type value: exec_result
  • Message meaning: Tool execution result

9

{"round_id": 1, "sub_id": 0, "type": "tool", "status": "tool_end", "msg": "{Parameters and results of tool invocation}"}

  • type value: tool
  • status:tool_end
  • Message meaning: Detailed information about tool invocation

9

{"round_id": 1, "sub_id": 0, "is_major": true, "type": "interpret", "content": "Based on query"}

  • type value: interpret
  • Message meaning: Message used for explanation after successful completion

10

{"round_id": 0, "sub_id": 0, "type": "result", "status": "success", "msg": "success", "result": {"historyId": 4225437, "dataSetId": 4250665}, "title": "Which cities in the supermarket dataset contain the character '北'", "round_title": "Which cities in the supermarket dataset contain the character '北'"}

  • type value: result
  • status:success
  • Message meaning: Message for generating historyId

11

{"round_id": null, "sub_id": 0, "type": "result", "status": "success", "msg": "success", "result": {"thought": "The user needs to analyze data trends, but has not specified the time range or the metric definition for analysis. According to the table information, multiple tables contain date fields and different metric fields. The user needs to specify the time range and metric definition.", "fuzzyRequirements": "The time range and metric definition for analysis need to be specified.", "suggestions": [{"options": [{"tableId": 4530118, "value": "2015-09-30 to 2022-01-05", "tableName": "zhouyf_simple_test_01", "fieldName": "Employment date", "appId": 1008919}, {"tableId": 4494668, "value": "2015-01-01 to 2018-12-30", "tableName": "mxl0903回归", "fieldName": "Order date", "appId": 555163}, {"tableId": 4494668, "value": "2015-01-03 to 2019-01-06", "tableName": "mxl0903回归", "fieldName": "Shipping date", "appId": 555163}], "description": "You have not specified a time range. Here are several possible time range options for you. Please select the appropriate time range.", "type": "Time range"}, {"options": [{"tableId": 4530127, "tableName": "zhouyf_simple_test_03", "fieldName": "Deposit balance (yuan)", "appId": 1008919}, {"tableId": 4494668, "tableName": "mxl0903回归", "fieldName": "Sales amount", "appId": 555163}, {"tableId": 4530123, "tableName": "zhouyf_simple_test_02", "fieldName": "Annual income (RMB 10,000)", "appId": 1008919}], "description": "You have not specified the metric definition for analysis. Here are several possible metric options for you. Please select the appropriate metric.", "type": "Metric definition"}], "toolCallId": "call_41cplq8c5exulc5jnzc8py1d"}, "title": "", "round_title": ""}

  • type type: result
  • status:success
  • Message meaning: Clarification message, user interaction required to confirm information

12

{"sub_id": 0, "round_id": 0, "is_major": true, "type": "report", "status": "success", "result": {"reportId": 11587438, "appId": 555371, "reportName": "Top customer Sales amount", "dataSetName": "Supermarket data - Zhixing (copy)", "dataSetId": 2978669, "dashboardId": 0, "dashboardName": null, "role": true, "whereList": [{"id": "10000006952807", "name": "Customer name length > 2", "op": "==", "option": {"customList": [], "desensitizationList": [], "displayType": "multiDropDownList", "filterPattern": "Condition", "isReportFilter": false}, "preRelation": "and", "uniqueId": 250710205658092, "val": [1], "valOption": {"currentTab": "manual"}}]}}

  • type type: report
  • status:success
  • Message meaning: Chart retrieval message

13

[DONE]

  • Message meaning: Conversation end message

Enumeration values for type

Enumeration value

Meaning

init

Chat initialization signal

report

The model returns a chart as the result

thought

Large model thought process, or the thought process for tool invocation (execution thinking).

exec_context

Execution process information for tool invocation (execution content).

exec_result

Summary of tool invocation results (execution result).

result

The model returns results, including clarification and final results

  • Clarification return fields:
    • thought: Clarification thought process.
    • fuzzyRequirements: Information requiring user interaction confirmation.
    • suggestions: Clarification selection results. The structure can refer to the structure of data.clarifyResults.userChoices in the request parameters.
  • Final result return fields:
    • historyId: The result ID of the current session. For example, when decomposing a fuzzy question into multiple sub-questions for querying, each sub-question result will have a session result ID.
    • dataSetId: The data set ID for querying the result returned for the current question.

code

Some model outputs, no need to pay attention.

tool

MCP tool invocation related information, used for key message exposure, no need to pay attention.

interpret

Data interpretation is enabled only when the "Enable chart analysis" switch is turned on in the "Basic information" section of the agent management console.

debug

Some debug key frame information, including the generation and results of voting, streaming heartbeat, and more.

Enumeration values for status

  • When type = result, status has the following enumeration values.

    Enumeration value

    Meaning

    failed

    Query failed.

    tip

    • In the returned message, status=failed does not necessarily indicate a query failure. When the agent enables "Multi-path execution", failures in individual rounds (round_id=1/2/3) can be ignored, and other rounds will automatically correct errors.
    • If "Multi-path execution" is not enabled, or if the primary link of "Multi-path execution" (round_id=0) has status=failed, it indicates a query failure.

    success

    Query succeeded.

    simple_text_shut_down

    Simple question and answer ended.

  • When type = tool, status has the following enumeration values.

    Enumeration value

    Meaning

    tool_end

    Tool invocation ended.

Description of other data fields

  • round_id: When the agent enables [multi-path execution], multiple paths are initiated for querying. round_id is used to identify the query path.
  • is_major: Indicates whether it is the primary path.

warning

You only need to pay attention to messages with round_id=0 and is_major = true.

Last updated: 2026.06.02 14:53:15