Chat
Calls the Chat operation to initiate a conversation and interact with OSS Agent in natural language through streaming responses.
Usage notes
-
This operation uses Server-Sent Events (SSE) streaming responses. The client must support streaming reads.
-
The sessionId is used to maintain conversation context. Multiple requests within the same conversation must use the same sessionId.
Request syntax
POST /api/chat/stream HTTP/1.1
Request parameters
Parameter |
Type |
Required |
Description |
sessionId |
string |
Yes |
The conversation session ID. Used to identify a complete conversation context. Example: |
messages |
array<object> |
Yes |
The message list. Contains messages sent by the user to the Agent. |
messages[].role |
string |
Yes |
The role of the message. Example: |
messages[].content |
string |
Yes |
The text content of the conversation. Example: |
Response parameters
This operation uses Server-Sent Events (SSE) streaming responses and returns the Agent's reply in chunks. Each chunk is a JSON-formatted string.
Parameter |
Type |
Description |
id |
string |
The unique identifier of the response. |
object |
string |
The object type. Example: |
created |
integer |
The Unix timestamp when the response was created. |
choices |
array<object> |
The list of reply choices. Each element contains |
Examples
Sample request:
POST /api/chat/stream HTTP/1.1
Content-Type: application/json
{
"sessionId": "550e8400-e29b-41d4-a716-446655440000",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}
Sample response:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"object": "chat.completion.chunk",
"created": 1785476706,
"choices": [
{
"index": 0,
"delta": {
"role": "assistant",
"content": "Checking the health status of your bucket..."
}
}
]
}