ChatMessages

Updated at:

Sends a conversation message.

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

rdsai:ChatMessages

none

*All Resource

*

None None

Request syntax

POST /v1/chat-messages HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

Query

string

No

The query content.

Disk usage of instance rm-bp14as9914vd3****, and whether it needs to be scaled up

ConversationId

string

No

The conversation ID.

fea7bdca-e848-44dd-b1ae-852472b8****

ParentMessageId

string

No

The parent message ID.

84dc9f9b-424a-404d-9c36-35e9d000****

Inputs

object

No

The task input.

CustomAgentId

string

No

The custom agent ID.

d1b7d639-f34e-44c7-8231-987da14d****

RegionId

string

No

The region ID.

cn-beijing

Timezone

string

No

The time zone. Default value: Asia/Shanghai.

UTC

Language

string

No

The conversation language.

zh-cn

EnableThinking

string

No

Specifies whether to enable the deep thinking mode.

true

ThinkEffort

string

No

The thinking depth.

Valid values:

  • default :

    Automatic.

  • high :

    Reasoning.

  • low :

    Fast.

default

ModelId

string

No

The model ID.

qwen3.7-max

WorkspaceId

string

No

The ContextDB workspace ID.

00000000-0000-4000-8000-000000000001

ToolApprovalMode

string

No

Specifies the tool approval mode for the current conversation. Valid values: read_only (read-only, rejects write tools), manual (write tools require manual approval), and auto (automatically determined by the approval sub-agent; escalated to manual approval when needs_human is returned). If specified, updates the approval mode of the current conversation.

manual

ResumeCallId

string

No

The tool approval call ID for resuming execution. Pass this parameter after the console completes all decisions for the current approval round to continue the interrupted ChatMessage loop. Do not pass this parameter for normal conversations.

call-example

FlowId

string

No

The IM flow ID. Used to bind messages to a registered IM channel when a conversation is initiated through an IM channel.

flow-xxxxxxxxxx

EventMode

string

No

The event output mode. Valid values: inline and separate. Default value: inline. When set to inline, tool invoke events, child node events, and document events are unified into the answer field of the event where event = message. When set to separate, tool invoke events, child node events, and document events have their own respective events.

inline

Files

array<object>

No

The list of attachments included in the current conversation round. References uploaded files by using UploadFileId.

object

No

Type

string

No

The attachment type. A value of image indicates an image. The actual supported types are determined by the file upload configuration of the application.

image

TransferMethod

string

No

The file transfer method. Set this parameter to local_file and provide the UploadFileId when referencing an uploaded file.

local_file

UploadFileId

string

No

The identifier of the uploaded file. The ContextDB management agent can use the UploadFileId returned by the knowledge base of the current workspace.

00000000-0000-4000-8000-000000000001

Url

string

No

The image URL.

https://other-general-huadong1.oss-cn-hangzhou.aliyuncs.com/uploadWidget/BirthCertification_0.jpeg

Response elements

Element

Type

Description

Example

object

The object.

RequestId

string

The request ID.

FE9C65D7-930F-57A5-A207-8C396329****

Answer

string

The answer content.

The disk usage of the instance rm-bp14as9914vd3**** you asked about is 23%, and it does not need to be scaled up at the moment. If you need to further view the detailed configuration, performance monitoring, or perform other operations for a specific instance, please let me know your specific requirements!

ConversationId

string

The conversation ID.

9cbbe885-b240-4803-9d15-6781a3fd****

CreatedAt

integer

The creation time.

1763986004

MessageId

string

The message ID.

oas8pwy2-slxw-sf98-bx83-cb2hkktl****

Mode

string

The query mode.

This will be deprecated in the future. You can ignore it

Event

string

The event.

MysqlIOException

Id

string

The message ID.

60b335ca-124d-4ee1-864b-de554987****

TaskId

string

The asynchronous task ID.

01c3d43d-9466-4bd5-8196-4cbbce08****

RoundId

string

The tool approval round ID.

round-example

CallId

string

The tool invoke ID.

call-example

ToolName

string

The tool name.

contextdb.search

ToolArguments

object

The tool invoke parameters.

Description

string

The tool invoke description.

Search ContextDB records

ApprovalStatus

string

The tool invoke approval status.

pending

Examples

Success response

JSON format

{
  "RequestId": "FE9C65D7-930F-57A5-A207-8C396329****",
  "Answer": "The disk usage of instance rm-bp14as9914vd3**** is 23%. Capacity expansion is not required at this time. Let me know if you need to view detailed configurations, performance monitoring, or perform other operations for a specific instance",
  "ConversationId": "9cbbe885-b240-4803-9d15-6781a3fd****",
  "CreatedAt": 1763986004,
  "MessageId": "oas8pwy2-slxw-sf98-bx83-cb2hkktl****",
  "Mode": "This will be deprecated in the future and can be ignored",
  "Event": "MysqlIOException",
  "Id": "60b335ca-124d-4ee1-864b-de554987****",
  "TaskId": "01c3d43d-9466-4bd5-8196-4cbbce08****",
  "RoundId": "round-example",
  "CallId": "call-example",
  "ToolName": "contextdb.search",
  "ToolArguments": {
    "test": "test",
    "test2": 1
  },
  "Description": "Search ContextDB records",
  "ApprovalStatus": "pending"
}

Error codes

HTTP status code

Error code

Error message

Description

451 ContentModeration Content moderation violation. Non-compliant content in request
400 InvalidParameter The provided parameter is invalid. Invalid parameter.
400 InvalidOrder No valid order found, please check whether RDS Copilot Professional Edition has been activated and ensure that the order is valid. No valid order found, please check whether RDS Copilot Professional Edition has been activated and ensure that the order is valid.
400 FileUploadValidationError The uploaded file reference is invalid. The uploaded file reference is invalid.
400 InvalidWorkspaceId.Missing WorkspaceId is required for the ContextDB management App. WorkspaceId is required when using ContextDB to manage applications. Specify the ContextDB workspace to which this request belongs and try again.
400 InvalidWorkspaceId.Conflict The request contains conflicting WorkspaceId values. The WorkspaceId values provided in the request conflict with each other. Ensure that the workspace identifiers are consistent across all locations in the request and try again.
400 InvalidWorkspaceId.Value WorkspaceId is invalid. The WorkspaceId is invalid. Check the workspace identifier, specify a valid ContextDB WorkspaceId, and try again.
422 InvalidToolApprovalMode Invalid ToolApprovalMode value. The ToolApprovalMode parameter value is invalid.
403 ModelSelectionRequiresPaidOrder Selecting a non-default model requires a valid paid order. Selecting a non-default model requires a valid paid order.
403 FileUploadForbidden The uploaded file is not accessible to the current user. The current user does not have permission to access the uploaded file.
404 UserNotFound User does not exist. User does not exist.
404 CustomAgentNotFound The custom agent was not found or is not accessible. The custom smart body does not exist or the current user does not have access.
503 ToolApprovalUnavailable The tool approval service is temporarily unavailable. The tool approval service is temporarily unavailable. Try again later.
429 TooManyRequests The current maximum concurrent requests have exceeded the threshold. The current maximum number of concurrent requests has exceeded the threshold. Purchase a AI package to increase the concurrency limit or reduce the current number of concurrent requests.
429 MoQuotaExceeded The MO token quota of the routed Standard instance has been exhausted and the request is rate limited. Please wait for quota recovery or purchase a capacity pack. The MO token quota of the routed Standard Edition instance has been exhausted. Please wait for the quota to be restored or purchase a capacity package.
429 RateLimitError The request was rejected because the invocation rate limit was exceeded. The request was rejected because it exceeded the call frequency limit.
409 PendingToolApproval The conversation has pending tool approvals. Conversation there are pending tool approvals, complete all approvals before continuing the conversation.
409 ToolApprovalResumeInvalid The specified tool approval call cannot be resumed. The specified tool approval invocation cannot be resumed.
409 ConversationBusy The conversation is already resuming a tool approval round. The conversation is resuming tool approval. The current request cannot be executed concurrently.
409 FileUploadConflict The uploaded file conflicts with the current request. The upload file conflicts with the current request.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.