All Products
Search
Document Center

Realtime Compute for Apache Flink:ChatAiAgent

Last Updated:Oct 19, 2026

Initiates a streaming conversation with an AI agent.

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

stream:ChatAiAgent

none

*All Resource

*

None None

Request syntax

POST /advisor/v2/namespaces/{namespace}/ai-agent/stream/agent/v2/chat HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

namespace

string

Yes

The project name.

test-flink-bigdata-default

Request parameters

Parameter

Type

Required

Description

Example

workspace

string

Yes

The workspace ID.

710d6a64d8****

body

object

No

The resource specification.

userMessage

string

No

The natural language input from the user (1 to 64000 characters).

“”

sessionId

string

No

The session ID. If not provided, it is generated by the server. The same value must be passed for multi-turn conversations.

019F8CC7-EAD3-5E06-B0BF-3A2A0638B3DD-deliverData-20260723102220-VM8X0A5VZQ

refs

object

No

The resource references, including the job and skill lists.

jobs

array<object>

No

The list of job references.

object

No

The task ID.

deploymentId

string

No

Deployment ID

2a63abb7-7ae7-4902-9970-fe5cff4bd7c1

jobId

string

No

Job ID

ccb853c3-1d5a-438d-bf98-346815ad875a

skills

array

No

The list of skills to inject.

string

No

The skill.

[]

hitlDecisions

array<object>

No

The list of human-in-the-loop (HITL) approval decisions, used to resume sessions interrupted by hitlPending.

object

No

hitlId

string

No

The ID of the approval item corresponding to the hitlPending event.

-

decision

string

No

The approval decision: approve or deny.

Valid values:

  • deny :

    Deny.

  • approve :

    Approve.

approve

Response elements

Element

Type

Description

Example

object

event

string

The event type.

-

sessionId

string

The ID of the current session.

462E2707-590E-51B6-9940-0AB33044828B-deliverData-202603020950-WCSN4MEC8T

text

string

The text output from the assistant.

-

completed

boolean

Indicates whether the text segment is completed (the last segment of its message).

true

toolName

string

The name of the tool function.

"get_job_events"

toolCallId

string

The tool calling ID, used to pair the invoke and result.

"c1"

displayName

string

The localized display name of the tool.

""

input

any

The key-value pairs of the tool input parameters. The structure varies based on toolName.

{ "namespace": "vvp-dev-team", "jobId": "aa91ec66-...", "deploymentId": "b78aae4c-..." }

success

string

Indicates whether the tool calling invoke is successful.

true

errorType

string

The error type on failure (only when success is false).

TIMEOUT

errorMessage

string

The error message on failure (only when success is false).

TIMEOUT

items

array<object>

The list of pending approval items.

object

--

hitlId

string

The ID of the approval item, used when passing back hitlDecisions.

""

toolName

string

The name of the intercepted tool.

“”

args

any

The original key-value pairs of the tool parameters.

[]

displayName

string

The display name of the tool.

“”

usage

object

The token usage.

inputTokens

integer

The number of input tokens.

10

outputTokens

integer

The number of output tokens.

5

totalTokens

integer

The total number of tokens.

15

message

string

The error message for error events.

“”

Examples

Success response

JSON format

{
  "event": "-",
  "sessionId": "462E2707-590E-51B6-9940-0AB33044828B-deliverData-202603020950-WCSN4MEC8T",
  "text": "-",
  "completed": true,
  "toolName": "\"get_job_events\"",
  "toolCallId": "\"c1\"",
  "displayName": "\"\"",
  "input": "{ \"namespace\": \"vvp-dev-team\", \"jobId\": \"aa91ec66-...\", \"deploymentId\": \"b78aae4c-...\" }",
  "success": "true",
  "errorType": "TIMEOUT",
  "errorMessage": "TIMEOUT",
  "items": [
    {
      "hitlId": "\"\"",
      "toolName": "“”",
      "args": "[]",
      "displayName": "“”"
    }
  ],
  "usage": {
    "inputTokens": 10,
    "outputTokens": 5,
    "totalTokens": 15
  },
  "message": "“”"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.