Agentic Search API
The AgenticSearch OpenAPI is based on the Agent Client Protocol (ACP) and provides Agent session management and message interaction in the JSON-RPC 2.0 format. You can create and manage Agent sessions, send messages and receive Server-Sent Events (SSE) streaming responses, resume after a disconnect, cancel running tasks, and handle human-in-the-loop (HITL) interactions that the Agent initiates.
| Service name | Protocol | Service description | API call QPS limit (including the Alibaba Cloud account and RAM users) |
| AgenticSearch session service | ACP / JSON-RPC 2.0 | Creates, queries, and deletes Agent sessions, interacts with messages, resumes after a disconnect, cancels tasks, and responds to human-in-the-loop requests. The message operation supports SSE streaming output. | 10. To raise the QPS limit, submit a ticket to contact technical support. |
Session lifecycle
All AgenticSearch operations act on an Agent session and share the same ACP endpoint. A typical integration follows this sequence:
-
Create a session — Call
session/newto create a session and obtain asessionId. -
Send a message — Call
session/promptwith thesessionIdto send user input. The operation returns an SSE stream that you process frame by frame. -
Respond to HITL requests — When the SSE stream delivers
sessionUpdate=hitl_question, callsession/hitlRespondto submit the user answer, then continue processing the stream. -
Resume after a disconnect — If the connection drops, call
session/loadto resume the SSE stream from where it stopped. -
Cancel a running task — Call
session/cancelto stop the task that is running in a session. -
Delete a session — Call
Callsession/deleteto remove a session that is no longer needed.session/listat any time to query existing sessions.
Prerequisites
-
Authentication credentials — The platform authenticates the caller when you call AI Search open platform services through the API. For information about how to obtain the authentication information, see Obtain authentication information.
-
Service endpoint — You can call the service over the Internet or over a VPC. For more information, see Service endpoints.
Common request description
Request endpoint
All ACP operations use the same endpoint. The method field specifies the operation type.
POST {host}/v3/openapi/workspaces/{workspace-name}/agent/acp
Content-Type: application/json
Parameters:
-
host: the endpoint that you use to call the service. You can call the service over the Internet or over a VPC. For more information, see Service endpoints. -
workspace-name: the name of the workspace. For example,default.
Header parameters
| Parameter | Type | Required | Description | Example |
| Content-Type | String | Yes | The request content type. | application/json |
| Authorization | String | Yes | The API key authentication information. | Bearer OS-d1**2a |
Common request parameters
The following parameters apply to all methods. Parameters that apply only to session/list are described in Query sessions: session/list.
| Parameter | Type | Required | Description | Example |
| jsonrpc | String | Yes | The JSON-RPC version. Set the value to 2.0. |
2.0 |
| method | String | Yes | The operation to call. | session/prompt |
| id | String | No | The request ID of the caller. The response returns this value. | 1774339902987004 |
| agentName | String | No | The Agent name. | openagent |
| params | Object | No | The parameters of the method. | {} |
method values
| method | Description | Response type |
session/new |
Creates a session. | JSON |
session/list |
Queries the session list or a specific session. | JSON |
session/prompt |
Sends a message. | SSE |
session/load |
Resumes after a disconnect. Used only when _meta.isReload=true. |
SSE |
session/cancel |
Cancels the task that is running in a session. | JSON |
session/delete |
Deletes a session. | JSON |
session/hitlRespond |
Submits a HITL user answer. | JSON |
Common response structure
Operations that return JSON share a common response envelope. The following table describes the top-level fields observed in every response.
| Field | Description |
| requestId | The request ID. |
| code | The status code. 200 indicates success. A non-200 code, such as 400 or 404, indicates an error. |
| message | null on success. On error, contains an error description. |
| data | The response payload. Contains the result object on success and is null in the basic error envelope. |
The data object contains the following fields:
| Field | Description |
| requestId | The request ID. |
| timestamp | The server timestamp. |
| jsonrpc | The JSON-RPC version. |
| id | Echoes the id value from the request. |
| result | The operation-specific result. The fields vary by operation. See each operation's response example. |
Operations with a response type of SSE stream session/update events instead of returning this envelope directly. For details, see the SSE events described under Send a message: session/prompt.
Create a session: session/new
Request example
{
"jsonrpc": "2.0",
"id": "1",
"method": "session/new",
"agentName": "openagent",
"params": {
"_meta": {
"sessionSource": "CHAT_OPEN_AGENT"
}
}
}
params
| Parameter | Type | Required | Description |
| _meta | Object | No | The metadata. |
The _meta object supports the following parameters:
| Parameter | Type | Required | Description |
| sessionId | String | No | The session ID that you specify. If you leave this parameter empty, the server generates the ID. |
| sessionSource | String | No | The session source. |
Response example
{
"requestId": "5c4d23db-1aea-41d2-8f88-92ee4a7c3355",
"code": 200,
"message": null,
"data": {
"requestId": "5c4d23db-1aea-41d2-8f88-92ee4a7c3355",
"timestamp": 1774493027019,
"jsonrpc": "2.0",
"id": "1",
"result": {
"sessionId": "7b1172ca-8ccb-4c3f-b0fb-c72dd248d3ef",
"modes": null,
"models": null
}
}
}
Query sessions: session/list
Request example
{
"jsonrpc": "2.0",
"id": "2",
"method": "session/list",
"sessionSource": "CHAT_OPEN_AGENT",
"pageNum": 1,
"pageSize": 10,
"params": {}
}
Top-level parameters
The following parameters apply only to session/list and are set at the top level of the request, alongside the common request parameters.
| Parameter | Type | Required | Description |
| sessionSource | String | No | Filters sessions by session source. |
| sessionCode | String | No | Queries an exact session by session ID. |
| pageNum | Integer | No | The page number. |
| pageSize | Integer | No | The number of entries per page. |
Response example
{
"requestId": "598b5734-6dbe-4b04-9c17-4cdf99d58b85",
"code": 200,
"message": null,
"data": {
"requestId": "598b5734-6dbe-4b04-9c17-4cdf99d58b85",
"timestamp": 1774494136385,
"jsonrpc": "2.0",
"id": "2",
"result": {
"sessions": [
{
"sessionId": "7b1172ca-8ccb-4c3f-b0fb-c72dd248d3ef",
"title": "New session",
"description": null,
"createdAt": 1774493075150,
"updatedAt": 1774493094825,
"_meta": {
"sessionSource": "CHAT_OPEN_AGENT",
"agentName": "openagent",
"status": "RELEASED",
"chatCount": 1
}
}
],
"nextCursor": null,
"total": 1
}
}
}
Send a message: session/prompt
session/prompt returns an SSE stream. Process the events that the server pushes frame by frame until the final result.stopReason arrives or the connection ends.
Request example
{
"jsonrpc": "2.0",
"id": "3",
"method": "session/prompt",
"agentName": "openagent",
"params": {
"sessionId": "7b1172ca-8ccb-4c3f-b0fb-c72dd248d3ef",
"prompt": [
{
"type": "text",
"text": "What is the weather in Beijing today"
}
],
"knowledgebase": ["chunks"],
"_meta": {
"sessionSource": "CHAT_OPEN_AGENT",
"enableThinking": true,
"agentMode": "CHAT",
"modelMode": "ultimate",
"enabledTools": ["tool_name"],
"promptId": "prompt_001"
}
}
}
params
| Parameter | Type | Required | Description |
| sessionId | String | Yes | The session ID. |
| prompt | List | Yes | The user input. Specify at least one entry. |
| knowledgebase | List | No | The names of the knowledge bases. |
| _meta | Object | No | The metadata. |
Each entry in the prompt list supports the following fields:
| Parameter | Type | Required | Description |
| type | String | Yes | The content type. Valid values: text, file, image. |
| text | String | Required when type is text. |
The text content. |
| url | String | Required when type is file or image. |
The URL of the file or image. |
| file_parse_id | String | No | The file parsing task ID. |
The _meta object supports the following parameters:
| Parameter | Type | Required | Description |
| sessionSource | String | No | The session source. |
| enableThinking | Boolean | No | Specifies whether to enable deep thinking. |
| agentMode | String | No | The Agent mode. Valid values: CHAT, AGENTSWARM. |
| modelMode | String | No | The model tier. Valid values: ultimate, lite. |
| enabledTools | List | No | The tools or capabilities that are enabled for this round. The platform defines the valid values. |
| promptId | String | No | The ID of the prompt template. The platform provides this ID. |
Files and images
When prompt.type is file or image, the following rules apply:
-
urlis required. -
The URL passes a security check. If the URL is invalid, an error is returned.
-
The server adds the corresponding file or image fields based on the type and continues the run.
SSE events
The following example shows an SSE event:
{
"requestId": "8608c827-353c-47ae-aad3-924f65d3e296",
"timestamp": 1777002233071,
"jsonrpc": "2.0",
"method": "session/update",
"params": {
"sessionId": "7b1172ca-8ccb-4c3f-b0fb-c72dd248d3ef",
"update": {
"sessionUpdate": "agent_message_chunk",
"content": {
"type": "text",
"text": "Beijing today..."
}
},
"_meta": {
"chatId": "669d9496-5cb2-43f6-840e-ca052f49739f",
"nextLogOffset": 45
}
}
}
The following table describes common sessionUpdate values:
| sessionUpdate | Description |
task_status |
The task status. |
user_message_chunk |
The replay of the user message. |
agent_message_start |
The assistant message starts. |
agent_message_chunk |
An increment of the assistant message. |
agent_message |
The complete assistant message. |
hitl_question |
The Agent asks the user a question. |
hitl_response |
The HITL question is answered. |
task_complete |
The task is complete. |
You can ignore event types that are not listed.
Resume after a disconnect: session/load
session/load applies to resume-after-disconnect scenarios. Set _meta.isReload to true. The operation responds over SSE.
To resume the stream without losing messages, collect the following values from the session/prompt SSE events and pass them to session/load:
-
Use the
_meta.chatIdvalue from the SSE events asrequestCode. -
Use the
_meta.nextLogOffsetvalue from the last processed SSE event asbeginLogOffset. The stream then continues from that offset.
Request example
{
"jsonrpc": "2.0",
"id": "4",
"method": "session/load",
"agentName": "openagent",
"params": {
"sessionId": "7b1172ca-8ccb-4c3f-b0fb-c72dd248d3ef",
"_meta": {
"isReload": true,
"requestCode": "669d9496-5cb2-43f6-840e-ca052f49739f",
"beginLogOffset": 45
}
}
}
params
| Parameter | Type | Required | Description |
| sessionId | String | Yes | The session ID. |
| _meta | Object | Yes | The reconnection parameters. |
The _meta object supports the following parameters:
| Parameter | Type | Required | Description |
| isReload | Boolean | Yes | Set the value to true. |
| requestCode | String | No | The conversation ID, which is the _meta.chatId value of the SSE event. If you leave this parameter empty, the server tries to find the active task in the current session. |
| beginLogOffset | Integer | No | Continues reading from the specified log offset. The default offset is 0. |
The response event format is the same as the format of session/prompt.
Cancel a task: session/cancel
Request example
{
"jsonrpc": "2.0",
"id": "5",
"method": "session/cancel",
"params": {
"sessionId": "7b1172ca-8ccb-4c3f-b0fb-c72dd248d3ef"
}
}
params
| Parameter | Type | Required | Description |
| sessionId | String | Yes | The session ID. |
Response example
{
"requestId": "e2996c03-c390-44c7-8704-5e1648083694",
"code": 200,
"message": null,
"data": {
"requestId": "e2996c03-c390-44c7-8704-5e1648083694",
"timestamp": 1774493270410,
"jsonrpc": "2.0",
"id": "5",
"result": {
"success": true,
"message": "The cancellation request was sent. 0 tasks were cancelled",
"cancelledCount": 0,
"totalActive": 0
}
}
}
Delete a session: session/delete
Request example
{
"jsonrpc": "2.0",
"id": "6",
"method": "session/delete",
"params": {
"sessionId": "7b1172ca-8ccb-4c3f-b0fb-c72dd248d3ef"
}
}
params
| Parameter | Type | Required | Description |
| sessionId | String | Yes | The session ID. |
Response example
{
"requestId": "fdcb43f4-8613-403c-9b82-a38b7dd42f44",
"code": 200,
"message": null,
"data": {
"requestId": "fdcb43f4-8613-403c-9b82-a38b7dd42f44",
"timestamp": 1777447455250,
"jsonrpc": "2.0",
"id": "6",
"result": {
"sessionId": "7b1172ca-8ccb-4c3f-b0fb-c72dd248d3ef",
"success": true,
"message": "The session was deleted"
}
}
}
HITL response: session/hitlRespond
When the SSE stream of session/prompt delivers sessionUpdate=hitl_question, display the question and submit the user answer through this operation.
Request example
{
"jsonrpc": "2.0",
"id": "7",
"method": "session/hitlRespond",
"params": {
"sessionId": "7b1172ca-8ccb-4c3f-b0fb-c72dd248d3ef",
"requestId": "",
"responseText": "I choose artificial intelligence and machine learning",
"selectedOption": "Artificial intelligence and machine learning"
}
}
params
| Parameter | Type | Required | Description |
| sessionId | String | Yes | The session ID. |
| requestId | String | No | The HITL request ID. This parameter can be empty. |
| responseText | String | Either this parameter or selectedOption. |
The reply text of the user. |
| selectedOption | String | Either this parameter or responseText. |
The option that the user selects. |
Provide at least one of responseText and selectedOption.
Response example
{
"requestId": "578ccdae-e0df-490d-b49c-313e94c08c02",
"code": 200,
"message": null,
"data": {
"requestId": "578ccdae-e0df-490d-b49c-313e94c08c02",
"timestamp": 1778467232264,
"jsonrpc": "2.0",
"id": "7",
"result": {
"status": "accepted"
}
}
}
Error responses
A request error returns the basic error envelope:
{
"requestId": "uuid",
"code": 400,
"message": "invalid request",
"data": null
}
The code field indicates the error type, and the message field describes the error.
An execution error may return an envelope that carries a JSON-RPC error object in data.error:
{
"requestId": "uuid",
"code": 404,
"message": "The session does not exist or you are not authorized to access it",
"data": {
"requestId": "uuid",
"timestamp": 1713859200000,
"jsonrpc": "2.0",
"id": "1",
"error": {
"code": 404,
"message": "The session does not exist or you are not authorized to access it",
"errorCode": "SESSION_NOT_FOUND"
}
}
}
The data.error object contains the following fields:
-
code— The error code. -
message— The error description. -
errorCode— The machine-readable error identifier. For example,SESSION_NOT_FOUND.