StartChat
Streams agent events through Server-Sent Events (SSE) and supports creating a new session or resuming an existing session.
Operation description
Request description
When you call this API operation, make sure that
AgentVersionis set toV2.If you do not specify
SessionId, a new session is created. If you specifySessionId, an existing session is resumed.The default value of
ModeisIaCCodeNormal. OnlyIaCCodeNormalandIaCCodePipelinemodes are supported. You cannot switch the mode for an existing session.The default value of
EnableThinkingistrue, which specifies whether to output thinking content. You can reset this parameter in each request.A maximum of five image attachments are supported. Each attachment can be up to 5 MiB in size and must be accessed by using the OssObjectKey in the current user directory.
ClientContextis a JSON string of the page context and can be up to 16 KiB in size. It is valid only inIaCCodeNormalmode.The response type is
text/event-stream. A successful HTTP connection does not mean that the business process is complete. You must continue to read the SSE stream until the final state is reached.When the
TASK_STATE_INPUT_REQUIREDstate is received, it indicates that the system is waiting for user input. This is not a failure state.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ros:StartChat |
none |
*All Resource
|
None | None |
Request syntax
POST HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| Query |
string |
No |
The user input. It cannot be empty or contain only whitespace characters. |
Create a ROS template for a VPC and a vSwitch |
| SessionId |
string |
No |
If you do not specify this parameter, a new session is created. If you specify this parameter, the existing session of the current user is resumed. |
7f4e2a8c6d9b4a1f8e3c5b7d2a6f9012 |
| EnablePartialMessage |
boolean |
No |
The compatibility field. V2 always returns an event stream through SSE, and the current service does not consume this field. |
true |
| Mode |
string |
No |
V2 supports only IaCCodeNormal or IaCCodePipeline. The default mode for a new session is IaCCodeNormal. You cannot switch the mode for an existing session. Valid values:
|
IaCCodeNormal |
| Attachments |
array<object> |
No |
The array of image attachments. A maximum of 5 attachments are supported. Only the image type is supported. |
[{"Type":"image","MimeType":"image/png","Name":"topology.png","OssObjectKey":"user-id/attachments/topology.png"}] |
|
object |
No |
The single attachment object. |
{} |
|
| Type |
string |
No |
The attachment type. V2 currently supports only image. Valid values:
|
image |
| MimeType |
string |
No |
The image media type. Supported values: image/png, image/jpeg, image/webp, and image/gif. |
image/png |
| Name |
string |
No |
The attachment file name. If you do not specify this parameter, the file name is obtained from OssObjectKey. |
topology.png |
| OssObjectKey |
string |
No |
The OSS object key in the current user directory. It cannot contain absolute paths or path traversal. |
user-id/attachments/topology.png |
| Url |
string |
No |
V2 does not support direct URL upload. Use OssObjectKey instead. |
https://example.com/topology.png |
| AgentVersion |
string |
No |
Pass V2 to route the request to the ROS Agent V2 backend. Valid values:
|
V2 |
| EnableThinking |
boolean |
No |
Specifies whether to output thinking content. Default value: true. You can reset this parameter in each request for the same session. |
true |
| RegionId |
string |
No |
The region for the current resource operation. |
cn-hangzhou |
| ClientReferenceId |
string |
No |
The client-defined session identifier. It is used only for the client to identify its own sessions. The server does not provide capabilities such as uniqueness verification and list filtering. |
07484e4b81708f7586 |
Response elements
|
Element |
Type |
Description |
Example |
|
string |
The SSE event stream. Each frame starts with data: and ends with an empty line. Continue reading until the final business state is reached. |
data: {"event":"..."} |
Examples
Success response
JSON format
"data: {\"event\":\"...\"}\n\n"
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.