ChatSse

Updated at:

Provides the public endpoint for the MaxAgent service.

Operation description

Calls this API to use the MaxAgent intelligent service, which provides features such as product consultation, business data query, and job diagnostics for MaxCompute. The API streams the agent's reasoning process, reply messages, and artifact events by using Server-Sent Events (SSE). Multiple calls with the same chatId share the same conversation context.

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

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

GET /api/v1/ai/chat/sse HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

prompt

string

No

The user question. You can leave this parameter empty when used with commandId, where the preset command provides the task input.

What projects do I have

chatId

string

Yes

The unique identifier for a multi-turn conversation. Conversations with the same chatId share the same context. The value must start with a lowercase letter or a digit, and can contain lowercase letters, digits, underscores (_), and hyphens (-). The value must be 1 to 64 characters in length.

1ee04bea-0488-46b6-b85b-827e3cd37e55

AkProven

string

No

The credential used to verify the ownership of the AccessKey (AK) identity. This parameter is automatically injected by the POP gateway during request forwarding. Callers do not need to pass this parameter.

auto-injected-by-pop

agentType

string

No

The agent type. Valid values: MaxAgent (default, MaxCompute intelligent assistant) and DataAgent (data analytics agent).

DataAgent

projectName

string

No

The name of the MaxCompute project. This parameter is used to specify the project context for the current conversation.

odps_project

projectSchemaModel

string

No

The identifier of the project schema model. The server does not use this parameter in the current version. Passing this parameter does not affect the call result.

default

source

string

No

The identifier of the call source. This parameter is passed to the agent context along with the request to mark the channel from which the current conversation is initiated.

openapi

x-acs-accept-language

string

No

The language of the reply. Valid values: zh-CN (default, Chinese) and en (English). Language values starting with en are processed as English. Values such as zh, zh-CN, zh-Hans, and zh-SG are processed as Chinese. Other values fall back to Chinese.

zh-CN

semanticPackId

string

No

The ID of the semantic pack. This parameter is used to specify the semantic pack context for DataAgent analysis. This parameter is optional. If you leave this parameter empty, no semantic pack is specified.

pack-sales

schemaName

string

No

The name of the MaxCompute schema. This parameter is used to specify the schema context for the current conversation in the three-level model (project.schema.table).

default

analysisMode

string

No

The analysis mode of DataAgent. Valid values: standard (standard mode, where the agent directly reasons and calls tools to complete the analysis) and deep (deep analysis mode, which delegates execution to the deep analysis engine). If you leave this parameter empty, the default mode is used.

standard

commandId

string

No

The ID of the preset command. This parameter is used to directly trigger a published command or Solutions workflow. You can call the GetAgentCommands operation to query active commands. When commandId is specified, the analysis pattern and node input are determined by the command definition.

task.analyze

reportOnCompletion

boolean

No

Specifies whether to automatically generate an interpretation report after the command execute is completed. If this parameter is set to true, commandId must point to a Solutions workflow. Otherwise, a 400 error is returned. Default value: false.

analysisRunId

string

No

The ID of an existing analysis run. The value is a 32-character lowercase hexadecimal string. This parameter is only used to re-initiate an interpretation for a completed analysis run. It cannot be used together with prompt, commandId, reportOnCompletion, or the deep mode. Otherwise, a 400 error is returned.

9f8e7d6c5b4a39281706f5e4d3c2b1a0

dashboardContext

string

No

The JSON string passed when starting a new standard DataAgent conversation in a dashboard. The value can be up to 32,768 characters in length. It includes the dashboard ID dashboardId, current version version, operation intent intent (read for interpretation, modify for modification), and optional clientFilters (up to 40 items). You must also provide prompt, set agentType to DataAgent, and omit the command, run ID, and auto-report options.

{"dashboardId":"01J8ZYK0Q4M5N6P7R8S9T0V1W2","version":1,"intent":"read"}

Response elements

Element

Type

Description

Example

string

The Server-Sent Events (SSE) event stream. For event types and JSON payloads, refer to the response description. The current execution ends with a done event, and errors are returned as error events.

event: message data: {"conversationId":"123456789012****#cn-shanghai#1ee04bea-0488-46b6-b85b-827e3cd37e55","turnId":"9f8e7d6c5b4a39281706f5e4d3c2b1a0","content":"You have the following projects: odps_project.","role":"assistant"}

Returns an SSE event stream. Each event consists of an event line (event type) and a data line (JSON payload). When the connection is idle, a heartbeat comment line is sent every 5 seconds to keep the connection alive. Event types include: message (reply message), reasoning (reasoning process), progress (execution progress), artifact (analysis artifact), action (operation pending user confirmation), agent_handoff (agent handoff), compact (context compaction), conversation_metadata_updated (conversation metadata update), command_accepted (command accepted), skill_activated (skill activated), command_rejected (command rejected), chat_cancelled (chat canceled), done (current turn ended), and error (error, the payload contains requestId). The payload of a message event includes the conversationId, turnId, content, and role fields.

Examples

Success response

JSON format

"event: message\ndata: {\"conversationId\":\"123456789012****#cn-shanghai#1ee04bea-0488-46b6-b85b-827e3cd37e55\",\"turnId\":\"9f8e7d6c5b4a39281706f5e4d3c2b1a0\",\"content\":\"You have the following projects: odps_project.\",\"role\":\"assistant\"}"

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.