Domain name for API request: cls.ai.intl.tencentcloudapi.com.
Call the API to initiate a dialogue request.
This API supports AI-powered logging features such as intelligently generating retrieval analysis statements.
Note: When calling this API via SSE streaming, ensure the request domain name is set to cls.ai.tencentcloudapi.com (configurable as cls.ai.internal.tencentcloudapi.com in a private network environment).
A maximum of 20 requests can be initiated per second for this API.
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| Action | Yes | String | Common Params. The value used for this API: ChatCompletions. |
| Version | Yes | String | Common Params. The value used for this API: 2020-10-16. |
| Region | Yes | String | Common Params. For more information, please see the list of regions supported by the product. |
| Model | Yes | String | Feature name Enumeration value:
|
| Messages.N | Yes | Array of Message | Chat context information.
|
| Stream | No | Boolean | Streaming call switch.
Note:
|
| Metadata.N | No | Array of MetadataItem | Additional metadata information. For example: [{"Key":"topic_id","Value":"xxxxxxxx-xxxx"},{"Key":"topic_region","Value":"ap-guangzhou"}] It is recommended to transmit metadata information as per the example, otherwise it may cause inaccurate results. For example, in text2sql, not passing topic_id or topic_region will lead to unable to generate accurate query statements based on the log topic index. |
| Parameter Name | Type | Description |
|---|---|---|
| Created | Integer | Unix timestamp, in seconds. |
| Usage | ChatUsage | Token statistical information. |
| Id | String | Id of the current request. |
| Choices | Array of Choice | Reply content. |
| Model | String | Feature name Enumeration value:
|
| RequestId | String | The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. As a streaming response API, when the request is successfully completed, the RequestId will be placed in the Header "X-TC-RequestId" of the HTTP response. |
This example shows you how to make streaming api calls and transmit historic session content. Note: Please make sure to configure the request domain for streaming calls as cls.ai.tencentcloudapi.com (use cls.ai.internal.tencentcloudapi.com in a private network environment).
POST / HTTP/1.1
Host: cls.ai.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ChatCompletions
<Common request parameters>
{
"Model": "text2sql",
"Messages": [
{
"Role": "user",
"Content": "Status code 200, number of statistical log entries"
},
{
"Role": "assistant",
"Content": "According to your needs \"status code 200, number of statistical log entries\", I analyzed this as a retrieval and analysis requirement. It requires retrieving logs with status code 200 and counting the number of log entries.\n\nBased on the field configuration of the Nginx log topic, the `status` field is of long data type and has statistics enabled. The following is the generated CQL statement:\n\n\\`\\`\\`sql\nstatus:200 | SELECT count(*) AS log_count\n\\`\\`\\`\n\n**Explanation:**\n1. **Retrieval condition**: `status:200` - retrieve logs with status code 200\n2. **SQL statement**: `SELECT count(*) AS log_count` - count the number of qualified logs\n3. **Verification result**: the statement passed validation\n\nSince this is a statistical query, the pipe character `|` is required to connect the retrieval condition and the SQL analysis statement. The statement uses `status:200` as the retrieval condition and then uses the `count(*)` function to count the number of log entries."
},
{
"Content": "Count 5xx again"
"Role": "user"
}
],
"Stream": true,
"Metadata": [
{
"Key": "topic_id",
"Value": "xxxxxxxx-xxxx"
},
{
"Key": "topic_region",
"Value": "ap-guangzhou"
}
]
}
id: 1
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"based on","Role":"assistant","ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103178,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 2
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"your needs\"","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103178,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 3
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Count 5","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103178,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 4
data: {"RequestId":"xx-xxxx","Id":"xx-xxxx","Choices":[{"Delta":{"Content":"xx's\","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103178,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 5
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"This is","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 6
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"To","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 7
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Statistics HTTP","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 8
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"status code is","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 9
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"5xx(","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 10
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"server error)","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 11
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"log entries","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 12
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"number.\n\n","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 13
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Based on log topic","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 14
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"field","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 15
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"list,`","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 16
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"status`","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 17
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"The field is long","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 18
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Type and enabled","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 19
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Statistics status.","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 20
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"the following is generated","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 21
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"CQL statement","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 22
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":":\n\n\`\`\`sql","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 23
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"\nstatus","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 24
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":">=500 AND","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 25
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":" status<=","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 26
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"599 |","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 27
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":" SELECT count(*)","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 28
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":" AS log","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 29
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"_count\n\`\`\`\n\n","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 30
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"**explanation","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 31
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":":**\n1","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 32
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":". **Retrieve","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103179,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 33
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Condition:","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 34
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"`status>=","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 35
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"500 AND status","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 36
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"<=599`","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 37
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":" - retrieve","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 38
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Status code in","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 39
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"500-","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 40
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"599 between","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 41
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Logs (5","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 42
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"xx server","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 43
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Error)\n2","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 44
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":". **","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 45
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"SQL statement**","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2SQL","Object":"chat.completion.chunk","Usage":{}}
id: 46
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":":`SELECT","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 47
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":" count(*) AS","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 48
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":" log_count`","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 49
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":" - statistics","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 50
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"logs that meet a specified condition","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 51
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"3\n3","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 52
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":". **Validate","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 53
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Result:","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 54
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Validate statement","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 55
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Passed\n\n","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 56
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"This","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 57
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"statement used","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 58
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"numeric value","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 59
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"range search","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 60
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"Condition","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103180,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 61
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"`status>=","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103181,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 62
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"500 AND status","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103181,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 63
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"<=599`","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103181,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 64
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"to match","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103181,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 65
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"ALL","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103181,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 66
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"5xx status","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103181,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 67
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"code,","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103181,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 68
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"then statistics","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103181,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 69
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"satisfy","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103181,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 70
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":"number of logs","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103181,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 71
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":".","Role":null,"ReasoningContent":null},"Index":0,"FinishReason":null}],"Created":1775103181,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{}}
id: 72
data: {"RequestId":"xxxxxxxx-xxxx","Id":"xxxxxxxx-xxxx","Choices":[{"Delta":{"Content":null,"Role":null,"ReasoningContent":null},"Index":0,"FinishReason":"stop"}],"Created":1775103181,"Model":"text2sql","Object":"chat.completion.chunk","Usage":{"PromptTokens":12482,"CompletionTokens":175,"TotalTokens":12657}}
This example shows you how to pass a non-streaming API call.
POST / HTTP/1.1
Host: cls.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ChatCompletions
<Common request parameters>
{
"Messages": [
{
"Content": "Status code 200, number of statistical log entries"
"Role": "user"
}
],
"Model": "text2sql-reasoning",
"Metadata": [
{
"Key": "topic_region",
"Value": "ap-guangzhou"
},
{
"Key": "topic_id",
"Value": "xxxxxxxx-xxxx"
}
]
}
{
"Response": {
"RequestId": "xxxxxxxx-xxxx",
"Id": "xxxxxxxx-xxxx",
"Created": 1775102996,
"Model": "text2sql-reasoning",
"Choices": [
{
"FinishReason": "stop",
"Message": {
"Role": "assistant",
"Content": "\n\`\`\`sql\nstatus:200 | SELECT count(*) AS \"log count\"\n\`\`\`\n\n### Explanation:\n1. **Retrieval criteria**: `status:200`\n - Use key-value search to filter logs with status code 200\n - The `status` field has statistics enabled (status is 1) in index configuration and can be used directly\n\n2. **Analysis statement**: `SELECT count(*) AS \"log count\"`\n - Use aggregate function `count(*)` to count the number of qualified logs\n - Field alias is wrapped in double quotes (contain Chinese)\n\n3. **Notes**:\n - This statement counts the number of logs within a specified time range\n - If needed, adjust time range on the console right side time selector\n - The `status` field is of long data type and supports exact numeric literal search\n\n### Verification result:\n\`\`\`json\n{\n \"status\": \"success\",\n \"result\": {\n \"log count\": 15234\n }\n}\n\`\`\`"
"ReasoningContent": "\nWe know the log topic index configuration field list, including the field: status:long::1, which means the status field is of long type with statistics enabled.\nThe requirement is: status code 200, count the number of log entries.\nAccording to the rule, pure statistical requirements should use the search and analysis format: [retrieval condition] | [sql statement]\nRetrieval condition: status code 200, i.e., status:200\nSQL statement: count the number of log entries, i.e., SELECT count(*) AS log_count\n\nNote: Since the status field has statistics enabled in the index configuration, it can be used directly.\n\nOutput CQL statement: `status:200 | SELECT count(*) AS log_count`\n\nExplanation: The retrieval condition is status:200, and then use SQL to count the number of log entries.\n\nMoreover, since the requirement specifies status code 200, we do not need to consider the time range because users can select the time range on the interface.\n\nVerification: We can simulate the verification. If there are logs with the status field and a value of 200, count their number. If the logs have no status field or no logs with a value of 200, return 0.\n\nSince we use a field with statistics enabled, there will be no issue of the field not being enabled with statistics.\n\nTherefore, the final output is as follows:"
"ToolCalls": []
},
"Index": 0
}
],
"Usage": {
"PromptTokens": 11262,
"CompletionTokens": 448,
"TotalTokens": 11710
}
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
| Error Code | Description |
|---|---|
| FailedOperation.Timeout | Operation timed out |
| ResourceNotFound.TopicNotExist | The log topic does not exist. |
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan