tencent cloud

Dialog API Documentation (HTTP SSE)
Last updated:2025-11-25 11:20:55
Dialog API Documentation (HTTP SSE)
Last updated: 2025-11-25 11:20:55
HTTP SSE is a one-way communication channel. After the client initiates an HTTP request, the server continuously pushes streaming data to the client. At this point, two-way interaction is not supported.

HTTP SSE API Request

Request Address: https://wss.lke.tencentcloud.com/v1/qbot/chat/sse.
Request Method: POST.
Note:
Before triggering the dialogue API, you need to have a published application.

1.1 Parameter Description

Place it in the HTTP Body and send it in JSON form as follows:
Name
Type
Required or Not
Description
request_id
string(255)
Yes
Request ID, used to identify a request (for message concatenation, it is recommended to use a different request ID per request).
content
string(6000)
Yes
Message content. If sending a picture, transmit the image link in markdown format, such as ![](image link), where the image link must be public read.
file_infos
Object array
No
File information. If you fill in this field, the content field can be empty. For data structure, refer to file_infos, dependent on file dialogue (real-time document parsing + dialogue).
Note:
When there is no file information, this field can be left blank or specified as an empty array.
session_id
string(64)
Yes
Conversation ID, used to identify a session (provided by an external system, it is recommended to import different session IDs for different user clients, otherwise messages from different users within the same application may get mixed up).
Parameter length: 2-64 characters
Verification rule: ^[a-zA-Z0-9_-]{2,64}$. You can use uuid to generate this value.
uuid example: 1b9c0b03-dc83-47ac-8394-b366e3ea67ef
bot_app_key
string(8)
Yes
Application key (see 1.2 How to Obtain AppKey chapter)
visitor_biz_id
string(64)
Yes
Visitor ID (external input, recommended to be unique, indicates the current user of the session)
streaming_throttle
int32
No
Streaming reply frequency control: Controls the response packet frequency of the application. This value indicates how many characters the application accumulates before sending a reply to the caller. A smaller value means more frequent replies (smoother experience but higher traffic overhead). If no value is provided or it is set to 0, the system configuration is used as the standard.
Default value: 5
Recommended maximum value: 100
Note: This setting does not accelerate the model output time, it merely changes the frequency of responses to the caller. Therefore, if set too high, there may be long periods with no response.
custom_variables
map[string]string
No
Workflow scenarios:
User-defined parameters can be used to pass parameters to the API parameter field of the workflow start node. These parameters can be recognized and used by the workflow. For details, refer to the start node operation instructions.

Set the value of the API parameter. You can configure multiple key:value pairs, where key is the name of the custom parameter and value is its runtime value.
Note:
Both the key and value in the map are of string type, for example {"UserID":"10220022"}. Invalid parameters include: {"UserID": 10220022}. The value can also be a json string, such as {"Data": "{\\"UserID\\":\\"10220022\\",\\"Score\\":{\\"Chinese\\":89,\\"Math\\":98}}"}

Set knowledge base search scope scenario:
Custom parameters can be used to set the knowledge base search scope. If multiple parameter values need to be input, separate them with vertical bars (|), for example: "user1|user2".
Note:
If you need to specify a knowledge base for retrieval in a question, you can input relevant tag values through this field. For details, refer to Set Knowledge Base Search Scope.
system_role
string
No
Role directive (prompt content). When empty, use the application's default setting. When filled, use the current value.
Maximum value limit: Different models have differences in maximum values. Refer to the RoleLenLimit in the ListModel API.
incremental
bool
No
Control whether the content in reply and thinking events is incrementally output, false by default.
Note:
This field set to true only takes effect for reply and thinking events.
Reply event effect:


Thinking event effect:

search_network
string
No
Whether online search is enabled. Value ranges from...to...
Empty string: Follow application configuration
enable: Turn on online search
disable: Turn off online search
Note:
The value field is meaningless when application configuration is not enabled during searching.

model_name
string
No
Support importing a specified model during the dialogue process. Using different model names under the same session_id maintains context correlation.
Currently supported custom models include the following:
lke-deepseek-r1:DeepSeek-R1
lke-deepseek-v3:DeepSeek-V3
lke-deepseek-r1-0528:DeepSeek-R1-0528
Note:
Ensure the selected model has sufficient tokens or enable postpaid mode to avoid errors during use.
stream
string
No
Whether streaming is enabled. Value ranges from...to...
Empty string: Follow application configuration
enable streaming
disable: Non-streaming transmission
workflow_status
string
No
Whether the workflow is enabled. Value ranges from...to...
Empty string: Follow application configuration (The page has no entry to configure workflow and is selected by default)
enable: Enable workflow
disable: Disable workflow
Data structure of visitor_labels knowledge tag list:
Name
Type
Description
name
string
knowledge tag name
values
string array
Tag value
file_infos
Data structure of file information
Name
Type
Required or Not
Description
file_name
string
Yes
File Name
file_size
string
Yes
Real-time document parsing API response file size
file_url
string
Yes
Real-time document parsing API response file URL
file_type
string
Yes
File Type
doc_id
string
Yes
Real-time document parsing API response doc_id

1.2 How to Obtain AppKey

In the Application Management interface, find your running app (it must be published first), click call, and a "call information" window will pop up.



In the call information window, you can see the AppKey. Click copy to proceed.




1.3 Calling the API with Curl

curl -XPOST -vvv --no-buffer --location 'https://wss.lke.tencentcloud.com/v1/qbot/chat/sse' \\
--header 'Content-Type: application/json' \\
--data '{
"content": "message content"
"bot_app_key": "<your appkey>",
"visitor_biz_id": "<your visitor id>",
"session_id": "<your session_id>",
"visitor_labels": []
}'

1.4 Postman Call Example





2. HTTP SSE API Response

2.1 Reply Event

Event name: reply
Event orientation: backend > frontend
Note:
If is_evil == true in the received message, it means the message hit sensitive content and failed to send.
Due to concurrency overrun causing queue timeout, the "concurrency limit exceeded" error will be triggered.
Data structure:
Name
Type
Description
request_id
string(255)
Request ID, used to identify a request (for message concatenation, it is recommended to use a different request ID per request).
content
string
Message content
file_infos
Object array
File Information
record_id
string(64)
Message unique ID
related_record_id
string(64)
Associated message unique ID
session_id
string(64)
Conversation ID, used to identify a session (provided by an external system, it is recommended to import different session IDs for different user clients, otherwise messages from different users within the same application may get mixed up).
is_from_self
bool
whether sent by itself
(If sent by itself, display on the right side of the chat box; otherwise, on the left.)
can_rating
bool
This message record can be evaluated.
timestamp
int64
message timestamp (in seconds)
is_final
bool
Whether the message has been output
In streaming mode, messages are returned multiple times, each time overwriting the previous answer.
When is_final == true, the stop generation button hides and the like/dislike buttons appear.
is_evil
bool
whether it hits sensitive content
Note: After message uplink, sensitive content detection is first performed, and an [reply] event is returned to inform the detection result. Business logic processing proceeds only after sensitivity detection is passed.



is_llm_generated
bool
whether the model generates content
reply_method
uint8
Response method:
1: Large model reply
2: Unknown question reply
3: Rejected question reply
4: Sensitive reply
5: Accepted Q&A pair prioritized reply
6: Welcome message reply
7: Number of concurrencies exceeded reply
knowledge
Object array
Hit knowledge
custom_params
string array
User-customized business parameters for passing through business parameters in QA
Note: This field may be empty. When empty, the field is not returned.
work_flow
Object
Workflow debugging info
Note: This field may be empty. When empty, the field is not returned.
quote_infos
Object array
Quoted information.
Data structure of knowledge in cache hits:
Name
Type
Description
id
string
Hit knowledge ID
type
uint32
Knowledge type hit: 1: QA 2: Document fragment
Workflow debugging information data structure:
Name
Type
Description
workflow_name
string
workflow name
workflow_id
string
workflow ID
workflow_run_id
string
workflow run ID
option_cards
string array
tab
current_node
Object
Node Information
outputs
string array
Output Results
current workflow node info:
Name
Type
Description
NodeID
string
Node ID
NodeType
int32
Node type
0: unspecified
1: Start Node
2: Parameter Extraction Node
3: Large Model Node
4: Knowledge Q&A Node
5: Knowledge Retrieve Node
6: Tag Extraction Node
7: Code Execution Node
8: Tool Node
9: Logic Judgment Node
10: Reply Node → Message Node
11: Tab Node
12: Loop Node
13: Intent Recognition Node
14: Workflow Node
15: Plugin Node
16: End Node
NodeName
string
Node name
Status
int32
Status:
0: Initial state
1: Running
2: Run successfully
3: Execution failed
Input
string
Node input. json string (including ordinary string)
Output
string
Node output. json string (including ordinary string)
TaskOutput
string
Task output. (Original output)
FailMessage
string
exception message exception information exception error message
CostMilliSeconds
string
Node duration. If the node is called multiple times, the duration is the sum of all calls.
Reply
string
Reply content of the current node. Current parameter extraction, message node, and End reply node may not be empty.
BelongNodeID
string
ID
StatisticInfo
Object
LLM Statistical Information
LLM Statistical Information
Name
Type
Description
ModelName
string
Model Name
FirstTokenCost
uint32
First token duration
TotalCost
uint32
Reasoning total time
InputTokens
uint32
Input token count
OutputTokens
uint32
Output token count
TotalTokens
uint32
Input + output tokens

2.2 Token Statistics Event

token stat
Event orientation: backend > frontend
Data structure:
Name
Type
Description
session_id
string(64)
Session id
request_id
string(255)
Request id for sending corresponding event
record_id
string(64)
Message record id for sending corresponding event
status_summary
string
Conversation status: processing, success, failed
status_summary_title
string
Conversation status description
elapsed
int
Call duration: ms
token_count
int
Token consumption in this round's request (when containing multiple processes, calculations will be aggregated)
procedures
Object array
Invocation process list
Invocation process list data structure:
Name
Type
Description
name
string
English name, one-to-one with the title field
knowledge, large_language_model
title
string
Invocation process description, corresponding to the name field, with Chinese meanings as follows:
Call the knowledge base, large model reply
status
string
Invocation process status: processing, success, failed
input_count
int
Token consumption of this process input
output_count
int
Token consumption of this process output
count
int
Token consumption of this process: input + output
Example:
[
"token_stat",
{
"type": "token_stat",
"payload": {
"elapsed": 1616,
"order_count": 50000000,
"procedures": [
{
"count": 323,
"input_count": 308,
"name": "knowledge",
"output_count": 15,
"status": "success",
"title": "Call the knowledge base"
}
],
"record_id": "Hpe_20240625_185659_215_EsH2uf8L",
"request_id": "8PUcDU6xyQ-301747294000",
"session_id": "2d071ef7-ef76-44df-84a4-9210672ed700c8",
"status_summary": "success",
"status_summary_title": "Call the knowledge base"
"token_count": 323,
"used_count": 553
},
"message_id": "89d91395-06bc-4f2e-b240-06f7b4498b0c6e"
}
]

2.3 Reference Event

Event name: reference
Event orientation: backend > frontend
Data structure:
Name
Type
Description
record_id
string(64)
Message unique ID
references
Object array
Reference
Data structure of reference sources
Name
Type
Description
id
uint64
The ID usage method is divided into two parts. See the following two examples:
1. When the source type is 1, 2, or 3, you can call the detail list acquisition source API to view the reference details. If preview is needed, obtain the corresponding parameters through the above API and concatenate them for redirection: https://lke.tencentcloud.com/preview?id=${docid}&botBizId=${appid}&page=${page number of the redirected document}&name=${name of the redirected sheet}&test=1
Note:
The id field corresponds to the ReferBizIds field in DescribeRefer
2. When the source type is 4, the id represents the serial number of multiple reference sources.
type
uint32
Source type
1: QA
2: Document fragment
4: Online retrieved content
Note:
When type = 2, the reference returns data at document slice granularity, which needs to be used with the id field above. A document [doc_id] may contain multiple slices. Decide whether to deduplicate when showing.
url
string
When type = 2, the url is a custom redirect link set for externally referenced document opening.
When type = 4, the url is the host address of the online search results.
name
string
Reference source name
doc_id
uint64
Reference document ID
doc_biz_id
uint64
Reference document business ID. You can call the Document Detail API to check the basic information of the corresponding document.
doc_name
string
Reference document name
qa_biz_id
string
Reference QA business ID
Example:
Reference source type
1: Q&A
2: Document fragment
You can use the Tencent Cloud SDK DescribeRefer to view reference source details. At this point, the id field corresponds to the ReferBizIds field in DescribeRefer.
Event name: reference
[
"reference",
{
"type": "reference",
"payload": {
"record_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"references": [
{
"doc_biz_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"doc_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"doc_name": "100 Idioms and Their Historical Character Stories+ (1).docx"
"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"name": "100 idioms and their historical stories (1)"
"qa_biz_id": "0",
"type": 2,
"url": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
],
"trace_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
"message_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
]

2.4 Error Event

Event name: error
Event orientation: backend > frontend
Data structure:
Name
Type
Description
request_id
string(255)
Request ID, used to identify a request (for message concatenation, it is recommended to use a different request ID per request).
error
Object
Error
error data structure:
Name
Type
Description
code
uint32
Error Code
message
string
Error Message
Example:
event:reply
data:{"type":"reply","payload":{"can_rating":false,"content":"Who are you","from_avatar":"","from_name":"","is_evil":false,"is_final":true,"is_from_self":true,"is_llm_generated":false,"knowledge":null,"record_id":"83ecd23c-6283-48d0-ac5e-7d8ab604770d","related_record_id":"","reply_method":0,"request_id":"","session_id":"sse_session8","timestamp":1701330804,"trace_id":"5daf1726c254241810bb160b4c8efbed"},"message_id":"808727d6-260a-4b7f-8a70-99330feaef3f"}

event:reply
data:{"type":"reply","payload":{"can_rating":true,"content":"I am the Large Model Knowledge Engine, can answer various questions and provide information.","from_avatar":"https://qbot-1251316161.cos.ap-nanjing.myqcloud.com/avatar.png","from_name":"bot","is_evil":false,"is_final":true,"is_from_self":false,"is_llm_generated":true,"knowledge":[{"id":33386,"type":1},{"id":452,"type":1},{"id":33388,"type":1}],"record_id":"7cfaf2dc-8e95-475b-9aa5-d6a5d4358f71","related_record_id":"83ecd23c-6283-48d0-ac5e-7d8ab604770d","reply_method":1,"request_id":"","session_id":"sse_session8","timestamp":1701330805,"trace_id":"5daf1726c254241810bb160b4c8efbed"},"message_id":"21b3eb5b-b0eb-4a2c-907b-2a287ad26a34"}
event:error
data:{"type":"error","error":{"code":460004,"message":"application does not exist"}}
Note:
When using the API, judge whether the value is 200. If yes, return normally.

2.5 Thinking Event

Event name: thought
Event orientation: backend > frontend
Note:
This event currently only returns when using the DeepSeek-R1 model.
Data structure:
Name
Type
Description
elapsed
int
Call duration: ms
procedures
Object array
Invocation process list
record_id
string(64)
Message record id for sending corresponding event
request_id
string(255)
Request id for sending corresponding event
session_id
string(64)
Session id
trace_id
string
Link id
Data structure of procedures
Name
Type
Description
debugging
Object array
Debug process info
index
uint32
Process index
name
string
English name, one-to-one with the title field
title
string
Invocation process description, corresponding to the name field, with Chinese meanings as follows: call the knowledge base, large model reply, thinking
status
string
Status: processing - active, success - success, failed - failed
icon
string
Icon, used for show
elapsed
uint32
Current request execution time. Unit: ms.
Data structure for debugging:
Name
Type
Description
content
string
Debug output
effect



Example:
[
"thought",
{
"type": "thought",
"payload": {
"elapsed": 0,
"is_workflow": false,
"procedures": [
{
"debugging": {
The user is asking about the features of DeepSeek-R1 for the third time. The previous two responses already covered its high efficiency, long-context processing, versatility across multiple fields, security compliance, multilingual support, flexible deployment, and cost-effectiveness. Possible reasons for the repeated question include: - The user may not fully understand the previous response and needs a more concise summary. - They might want to confirm the accuracy of the information. - They could be checking for any new updates. - They may be testing response consistency. - They might need the information for a specific purpose, such as a report or model comparison. Next steps: - Verify if previous responses were comprehensive, checking for missing key features (e.g., training data, supported frameworks, specific performance metrics). - Consider if the user is interested in technical details like model structure, training methods, or practical applications.
},
"elapsed": 9954,
"icon": "https://lke-realtime-1251316161.cos.ap-guangzhou.myqcloud.com/icon/thinking.png",
"index": 0,
"name": "thought",
"plugin_type": 0,
"status": "processing",
"switch": "",
"title": "think"
"workflow_name": ""
}
],
"record_id": "piQ_20250208_140511_254_45ja7HPq",
"request_id": "rjbuFuYeDB-8487350785",
"session_id": "dfd04cd0-ef69-4fb6-a447-a0b44018a93f",
"trace_id": "9a9613dbaa9edd27958bd1180c524295 / piQ_20250208_140511_254_45ja7HPq",
"workflow_name": ""
},
"message_id": "7070ef0d-4c28-4d5a-abc8-2ea2e7fa027d"
}
]

Error Code

Error Code
Error Message
400
Request parameter error, see access documentation
460001
Token Verification Failure
460002
Event handler not found
460004
Application does not exist
460006
Message does not exist or insufficient permissions
460007
Session creation failed
460008
fail to render
460009
Visitor does not exist
460010
The session does not exist or insufficient permissions
460011
Exceeding the concurrency limit
460020
Model request timeout
460021
Knowledge base not released
460022
Failed to create visitor
460023
Message like/dislike failed
460024
Invalid tag
460025
Image Analysis failed
460031
The number of connections for this application has exceeded the request limit. Please try again later.
460032
Insufficient balance for the current application model
460033
Application does not exist or insufficient permissions
460034
Content too long
460035
Compute content too long, has been disabled
460036
Task flow node preview parameters are abnormal
460037
Search for resource used up, call failed
460038
The AppID request shows abnormal behavior, call failed

4. Quick Deploy

ADP-chat-client includes a complete process for establishing connections and sending/receiving messages. For detailed instructions, please refer to Integration Solution Based on the Official Open-Source Project ADP-chat-client to integrate your agent application into your own system, enabling you to embed conversational capabilities into your business workflows.

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback