StartChat

Updated at:

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 AgentVersion is set to V2.

  • If you do not specify SessionId, a new session is created. If you specify SessionId, an existing session is resumed.

  • The default value of Mode is IaCCodeNormal. Only IaCCodeNormal and IaCCodePipeline modes are supported. You cannot switch the mode for an existing session.

  • The default value of EnableThinking is true, 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.

  • ClientContext is a JSON string of the page context and can be up to 16 KiB in size. It is valid only in IaCCodeNormal mode.

  • 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_REQUIRED state is received, it indicates that the system is waiting for user input. This is not a failure state.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

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:

  • Auto :

    Auto mode.

  • IaCCodePipeline :

    IaCCode sales pipeline session mode.

  • IFlow :

    IFlow mode.

  • Diagnostic :

    Diagnostic mode.

  • ResourceDeployment :

    Resource deployment mode.

  • IaCCodeNormal :

    IaCCode normal session mode.

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 :

    Image attachment.

  • file :

    File attachment.

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:

  • V1 :

    ROS Agent V1

  • V2 :

    ROS Agent V2

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.