All Products
Search
Document Center

Intelligent Media Services:API reference

Last Updated:Jun 17, 2026

Overview

Class/Protocol

API

Description

ARTCAIChatEngineInterface

Messaging engine interface

state

Gets the engine connection state.

userInfo

Gets the current session user information.

sessionId

Gets the current session ID.

agentInfo

Gets the AI agent information for the current session.

agentResponeState

Gets the agent response status.

voiceIdList

Retrieves available voices.

delegate

Configures and queries callback events.

templateConfig

Configures and obtains TemplateConfig.

userData

Custom user information passed to the AI agent.

startChat

Starts a chat session.

endChat

Ends a chat session.

sendMessage

Sends a message. Any ongoing agent reply (thinking or replying) is interrupted before sending.

deleteMessage

Deletes a message.

queryMessageList

Requests historical messages.

interruptAgentResponse

Interrupts the current reply.

deleteMessage

Deletes a message.

startPlayMessage

Starts reading out a message.

stopPlayMessage

Stops reading out a message.

isPlayingMessage

Checks whether a message is being read out.

createAttachmentUploader

Creates an attachment uploader for sending messages with images, videos, or other files.

startPushVoiceMessage

Starts push-to-talk voice recording. Recording begins on tap and voice input is sent in real time. Requires recording permission.

finishPushVoiceMessage

Ends push-to-talk voice recording. Called when the button is released, indicating the voice message has been sent.

cancelPushVoiceMessage

Cancels push-to-talk voice recording. Called when the button is released, indicating the voice message sending is canceled.

destroy

Releases resources.

parseShareAgentChat

Parses the information about a shared agent.

generateShareAgentChat

Starts a conversation with a shared agent.

IARTCAIChatEngineCallback

Messaging engine callback events

onErrorOccurs

Called when an error occurs.

onRequestAuthToken

Requests an authentication token. Triggered when ChatEngine needs to log on to interactive messaging or when the logon token expires.

onEngineStateChange

Called when the connection state of the engine changes.

onReceivedMessage

Triggered when the agent sends a new reply or when a message status changes during the reply process.

onReceivedCustomMessage

Called when a custom message is received.

onUserMessageUpdated

Called when the user-sent message is updated.

onAgentResponeStateChange

Called when the response status of the agent changes.

onMessagePlayStateChange

Called when the readout status of a message from the AI agent changes.

ARTCAICallEngineFactory

Engine creation factory

createChatEngine

Creates a default agent engine.

API details

ARTCAIChatEngineInterface

state

Gets the engine connection state. For detailed states, see ARTCAIChatEngineState.

var state: ARTCAIChatEngineState { get }

userInfo

Gets the current session user information. For details, see ARTCAIChatUserInfo.

var userInfo: ARTCAIChatUserInfo? { get }

sessionId

Gets the current session ID.

var sessionId: String? { get }

agentInfo

Gets the AI agent information for the current session. For details, see ARTCAIChatAgentInfo.

var agentInfo: ARTCAIChatAgentInfo? { get }

agentResponeState

Gets the agent response status. For details, see ARTCAIChatAgentResponseState.

var agentResponeState: ARTCAIChatAgentResponseState { get }

voiceIdList

Retrieves available voices.

var voiceIdList: [String] { get }

delegate

Configures and queries callback events. For details, see ARTCAIChatEngineDelegate.

weak var delegate: ARTCAIChatEngineDelegate? { get set }

templateConfig

Configures and obtains TemplateConfig. For details, see ARTCAIChatTemplateConfig.

var templateConfig: ARTCAIChatTemplateConfig? { get set }

userData

Custom user information passed to the AI agent.

var userData: [String: Any]? { get set }

startChat

Starts a chat session.

func startChat(userInfo: ARTCAIChatUserInfo, agentInfo: ARTCAIChatAgentInfo, sessionId: String?)

Parameter

Type

Description

userInfo

ARTCAIChatUserInfo

The user information for joining the session.

agentInfo

ARTCAIChatAgentInfo

The AI agent information for joining the session.

sessionId

String?

The current session ID. If empty, defaults to a concatenation of userId and agentId.

endChat

Ends a chat session.

func endChat(needLogout: Bool)

Parameter

Type

Description

needLogout

Bool

Whether to log out. Set to false to reduce connection time on the next startChat call. Set to true when conversation is no longer needed.

sendMessage

Sends a message. Any ongoing agent reply (thinking or replying) is interrupted before sending.

func sendMessage(request: ARTCAIChatSendMessageRequest, completed:((_ msg: ARTCAIChatMessage?, _ error: NSError?) -> Void)?)

Parameter

Type

Description

request

ARTCAIChatSendMessageRequest

The content of the message to send.

completed

(_ msg: ARTCAIChatMessage?, _ error: NSError?) -> Void

The callback for message sending result.

deleteMessage

Deletes a message.

func deleteMessage(message: ARTCAIChatMessage, completed:((_ error: NSError?) -> Void)?)

Parameter

Type

Description

message

ARTCAIChatMessage

The message object.

completed

((_ error: NSError?) -> Void)?

The callback for the operation result.

queryMessageList

Requests historical messages.

func queryMessageList(request: ARTCAIChatMessageListRequest, completed:((_ msgList: [ARTCAIChatMessage]?, _ error: NSError?) -> Void)?)  

Parameter

Type

Description

request

ARTCAIChatMessageListRequest

The request model.

completed

(_ msgList: [ARTCAIChatMessage]?, _ error: NSError?) -> Void)?

The result callback.

interruptAgentResponse

Interrupts the current reply.

func interruptAgentResponse()

deleteMessage

Deletes a message.

func deleteMessage(dialogueId: String, completed:((_ error: NSError?) -> Void)?)

Parameter

Type

Description

dialogueId

String

The message ID.

completed

(_ error: NSError?) -> Void)?

The result callback.

startPlayMessage

Starts reading out a message.

func startPlayMessage(message: ARTCAIChatMessage, voiceId: String?, completed: ((NSError?) -> Void)?)

Parameter

Type

Description

message

ARTCAIChatMessage

The message to read out.

voiceId

voiceId

The voice ID.

completed

(_ error: NSError?) -> Void)?

The result callback.

stopPlayMessage

Stops reading out a message.

func stopPlayMessage()

isPlayingMessage

Checks whether a message is being read out.

func isPlayingMessage(dialogueId: String) -> Bool

createAttachmentUploader

Creates an attachment uploader for sending messages with images, videos, or other files.

func createAttachmentUploader() -> ARTCAIChatAttachmentUploader?

startPushVoiceMessage

Starts push-to-talk voice recording. Recording begins on tap and voice input is sent in real time. Requires recording permission.

Returns true on success. Returns false on failure, which may be caused by an incorrect status or disabled recording permission.

func startPushVoiceMessage(request: ARTCAIChatSendMessageRequest) -> Bool

Parameter

Type

Description

request

ARTCAIChatSendMessageRequest

The content of the message to send.

finishPushVoiceMessage

Ends push-to-talk voice recording. Called when the button is released, indicating the voice message has been sent.

func finishPushVoiceMessage(completed:((_ msg: ARTCAIChatMessage) -> Void)?)

Parameter

Type

Description

completed

(_ msg: ARTCAIChatMessage) -> Void)?

The result callback.

cancelPushVoiceMessage

Cancels push-to-talk voice recording. Called when the button is released, indicating the voice message sending is canceled.

func cancelPushVoiceMessage()

destroy

Releases resources.

func destroy()

parseShareAgentChat

Parses shared agent information.

func parseShareAgentChat(shareInfo: String) -> ARTCAIChatAgentShareConfig?

Parameter

Type

Description

shareInfo

String

The shared information.

generateShareAgentChat

Starts a conversation with a shared agent.

func generateShareAgentChat(shareConfig: ARTCAIChatAgentShareConfig, userId: String, completed: ((_ agentInfo: ARTCAIChatAgentInfo?, _ authToken: ARTCAIChatAuthToken?, _ error: NSError?, _ reqId: String) -> Void)?)    

Parameter

Type

Description

shareConfig

ARTCAIChatAgentShareConfig

The shared information.

userId

String

The user ID.

completed

(_ agentInfo: ARTCAIChatAgentInfo?, _ authToken: ARTCAIChatAuthToken?, _ error: NSError?, _ reqId: String) -> Void)?

The result callback.

ARTCAIChatEngineDelegate

onErrorOccurs

Called when an error occurs.

@objc optional func onErrorOccurs(error: NSError, requestId: String?)

Parameter

Type

Description

error

NSError

The error message.

requestId

String?

The message request ID. If not empty, an error occurred during message processing.

onRequestAuthToken

Requests an authentication token. Triggered when ChatEngine needs to log on to interactive messaging or when the logon token expires.

@objc optional func onRequestAuthToken(userId: String, responseBlock: @escaping (_ authToken: ARTCAIChatAuthToken?, _ error: NSError?)->Void)

onEngineStateChange

Called when the connection state of the engine changes.

@objc optional func onEngineStateChange(state: ARTCAIChatEngineState)

Parameter

Type

Description

state

ARTCAIChatEngineState

The current connection state of the agent.

onReceivedMessage

Triggered when the agent sends a new reply or when a message status changes during the reply process.

@objc optional func onReceivedMessage(message: ARTCAIChatMessage)

Parameter

Type

Description

message

ARTCAIChatMessage

The message object.

onReceivedCustomMessage

Called when a custom message is received.

@objc optional func onReceivedCustomMessage(text: String)

Parameter

Type

Description

text

String

The message content.

onUserMessageUpdated

Called when a user-sent message is updated.

@objc optional func onUserMessageUpdated(message: ARTCAIChatMessage)

Parameter

Type

Description

message

ARTCAIChatMessage

The message object.

onAgentResponeStateChange

Called when the response status of the agent changes.

@objc optional func onAgentResponeStateChange(state: ARTCAIChatAgentResponseState, requestId: String?)

Parameter

Type

Description

state

ARTCAIChatAgentResponseState

The response status.

requestId

String?

The current message session.

onMessagePlayStateChange

Called when the readout status of an AI agent message changes.

@objc optional func onMessagePlayStateChange(message: ARTCAIChatMessage, state: ARTCAIChatMessagePlayState)

Parameter

Type

Description

message

ARTCAIChatMessage

The message object.

state

ARTCAIChatMessagePlayState

The readout status.

ARTCAICallEngineFactory

CreateChatEngine

Creates a default agent engine.

public static func createChatEngine() -> ARTCAIChatEngineInterface