LANYINGDevelopers
Web & Mini ProgramiOSAndroidC++Server API

8 AI API#

8.1 Send a message and get an AI response#

PUT /ai/message/send
POST /ai/message/send

Request Header#

ParameterData TypeRequiredDescription
access-tokenstringfalseToken
app_idstringtrueApp ID
group_idint64falseThis field can be set only if access-token is an Admin token, means call this interface as an Admin for this group ID
user_idint64falseThis 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#

ParameterData TypeRequiredDefaultDescription
attachmentstringfalseAttachment: 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}
configstringfalseExtension fields used by the SDK
contentstringtrueMessage content
content_typeint32trueMessage type TEXT = 0;
IMAGE = 1;
AUDIO = 2;
VIDEO = 3;
FILE = 4;
LOCATION = 5;
COMMAND = 6;
FORWARD = 7;
extstringfalseExtension data
from_user_idint64falseSender's user ID
online_onlybooleanfalseWhether to deliver only to online users (default: false): true delivers only to online users; false delivers to both online and offline users.
related_midint64falseID 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.
targetsarray[int64]trueReceive user ID or group ID
transaction_idint64falseRequest 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.
typeint32trueTarget type: 1 for a user, 2 for a group.

Response Body#

● 200 Response data format:JSON

ParameterTypeDescription
codeint32Response code; 200 indicates success
dataobjectResult data
⇥ message_quota_usagedoubleNumber of AI messages consumed
⇥ messagesarray[object]Message list
⇥⇥ attachmentstringMessage attachment: When the message type is image/voice/video/file, this field will include the file url
⇥⇥ configstringExtension fields used by the SDK layer
⇥⇥ contentstringMessage content
⇥⇥ ctypestringMessage Content Type: TEXT - Text, IMAGE - Image, AUDIO - Voice, VIDEO - Video, FILE - File, LOCATION - Location, COMMAND - Custom, FORWARD - Forward Message
⇥⇥ extstringExtension data
⇥⇥ from_xidobjectMessage sender
⇥⇥⇥ device_snint32Device serial number
⇥⇥⇥ uidint64User ID
⇥⇥ msg_idint64MessageID
⇥⇥ timestampint64Message delivery timestamp (milliseconds)
⇥⇥ to_xidobjectMessage receiver
⇥⇥⇥ device_snint32Device serial number
⇥⇥⇥ uidint64User ID
⇥⇥ typestringMessage type: CHAT - one-to-one chat; GROUPCHAT - group chat
messagestringError information, null means success

Interface Description#

Generated API content with concise AI notes where context helps.