8 AI API#
8.1 Send a message and get an AI response#
PUT /ai/message/send
POST /ai/message/send
Request Header#
| Parameter | Data Type | Required | Description |
|---|---|---|---|
| access-token | string | false | Token |
| app_id | string | true | App ID |
| group_id | int64 | false | This field can be set only if access-token is an Admin token, means call this interface as an Admin for this group ID |
| user_id | int64 | false | This field can be set only if access-token is a user token, means call this interface as a group member for this user ID |
Request Body#
| Parameter | Data Type | Required | Default | Description |
|---|---|---|---|---|
| attachment | string | false | Attachment: This field needs to be set if the message type is image/voice/video/file.:{"url":"https://xxx" ,"dName":"1658890327124.amr","fLen":1670,"duration":1}{"url":"https://xxx" ,"dName":"1646751218948","fLen":508728,"width":828.0,"height":828.0} | |
| config | string | false | Extension fields used by the SDK | |
| content | string | true | Message content | |
| content_type | int32 | true | Message type TEXT = 0; IMAGE = 1; AUDIO = 2; VIDEO = 3; FILE = 4; LOCATION = 5; COMMAND = 6; FORWARD = 7; | |
| ext | string | false | Extension data | |
| from_user_id | int64 | false | Sender's user ID | |
| online_only | boolean | false | Whether to deliver only to online users (default: false): true delivers only to online users; false delivers to both online and offline users. | |
| related_mid | int64 | false | ID of the message affected by the operation. Set this field for READ_ACK or RECALL to identify the message being marked as read or recalled. | |
| targets | array[int64] | true | Receive user ID or group ID | |
| transaction_id | int64 | false | Request ID used for deduplication. If two requests with the same transaction_id arrive within a short period, the second request is ignored. Requests are not deduplicated when this field is omitted. | |
| type | int32 | true | Target type: 1 for a user, 2 for a group. |
Response Body#
● 200 Response data format:JSON
| Parameter | Type | Description |
|---|---|---|
| code | int32 | Response code; 200 indicates success |
| data | object | Result data |
| ⇥ message_quota_usage | double | Number of AI messages consumed |
| ⇥ messages | array[object] | Message list |
| ⇥⇥ attachment | string | Message attachment: When the message type is image/voice/video/file, this field will include the file url |
| ⇥⇥ config | string | Extension fields used by the SDK layer |
| ⇥⇥ content | string | Message content |
| ⇥⇥ ctype | string | Message Content Type: TEXT - Text, IMAGE - Image, AUDIO - Voice, VIDEO - Video, FILE - File, LOCATION - Location, COMMAND - Custom, FORWARD - Forward Message |
| ⇥⇥ ext | string | Extension data |
| ⇥⇥ from_xid | object | Message sender |
| ⇥⇥⇥ device_sn | int32 | Device serial number |
| ⇥⇥⇥ uid | int64 | User ID |
| ⇥⇥ msg_id | int64 | MessageID |
| ⇥⇥ timestamp | int64 | Message delivery timestamp (milliseconds) |
| ⇥⇥ to_xid | object | Message receiver |
| ⇥⇥⇥ device_sn | int32 | Device serial number |
| ⇥⇥⇥ uid | int64 | User ID |
| ⇥⇥ type | string | Message type: CHAT - one-to-one chat; GROUPCHAT - group chat |
| message | string | Error information, null means success |