Skip to navigation

VoiceAgentAPIClient

View as Markdown

Methods

addEventListener

Adds a handler for the specified QwenCloud.VoiceAgentAPIEvents or QwenCloud.Events event. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called.

addEventListener(event: QwenCloud.Events | QwenCloud.VoiceAgentAPIEvents | T, callback: (event: QwenCloud._VoiceAgentAPIClientEvents[T]) => any): void

Parameters

event
QwenCloud.Events | QwenCloud.VoiceAgentAPIEvents | TRequired
callback
(event: QwenCloud._VoiceAgentAPIClientEvents[T]) => anyRequired

clearMediaBuffer

Clears the Qwen Cloud WebSocket media buffer.

clearMediaBuffer(parameters?: ClearMediaBufferParameters): void

Parameters

parameters
ClearMediaBufferParameters

close

Closes the Qwen Cloud connection (over WebSocket) or connection attempt.

close(): void

conversationItemCreate

Inserts a conversation item (message, function_call, or function_call_output). https://docs.qwencloud.com/api-reference/qwen-audio-realtime/client-events#conversation-item-create

conversationItemCreate(parameters: Object): void

Parameters

parameters
ObjectRequired

conversationItemDelete

Deletes a conversation item. https://docs.qwencloud.com/api-reference/qwen-audio-realtime/client-events#conversation-item-delete

conversationItemDelete(parameters: Object): void

Parameters

parameters
ObjectRequired

conversationItemRetrieve

Retrieves a conversation item. Audio content is returned as a transcript. https://docs.qwencloud.com/api-reference/qwen-audio-realtime/client-events#conversation-item-retrieve

conversationItemRetrieve(parameters: Object): void

Parameters

parameters
ObjectRequired

id

Returns the VoiceAgentAPIClient id.

id(): string

inputAudioBufferClear

Clears uncommitted input audio. Push-to-talk mode only. https://docs.qwencloud.com/api-reference/qwen-audio-realtime/client-events#input-audio-buffer-clear

inputAudioBufferClear(parameters?: Object): void

Parameters

parameters
Object

inputAudioBufferCommit

Commits the input audio buffer. Push-to-talk mode only. Does not start a response; call QwenCloud.VoiceAgentAPIClient.responseCreate after this. https://docs.qwencloud.com/api-reference/qwen-audio-realtime/client-events#input-audio-buffer-commit

inputAudioBufferCommit(parameters?: Object): void

Parameters

parameters
Object

removeEventListener

Removes a handler for the specified QwenCloud.VoiceAgentAPIEvents or QwenCloud.Events event.

removeEventListener(event: QwenCloud.Events | QwenCloud.VoiceAgentAPIEvents | T, callback?: (event: QwenCloud._VoiceAgentAPIClientEvents[T]) => any): void

Parameters

event
QwenCloud.Events | QwenCloud.VoiceAgentAPIEvents | TRequired
callback
(event: QwenCloud._VoiceAgentAPIClientEvents[T]) => any

responseCancel

Cancels the response currently being generated. https://docs.qwencloud.com/api-reference/qwen-audio-realtime/client-events#response-cancel

responseCancel(parameters?: Object): void

Parameters

parameters
Object

responseCreate

Starts a response. Required in push-to-talk mode and after a function_call_output. Optional overrides: response.modalities, response.voice. https://docs.qwencloud.com/api-reference/qwen-audio-realtime/client-events#response-create

responseCreate(parameters?: Object): void

Parameters

parameters
Object

sendMediaTo

Starts sending media from Qwen Cloud (via WebSocket) to the media unit. Qwen Cloud works in real time.

sendMediaTo(mediaUnit: VoxMediaUnit, parameters?: SendMediaParameters): void

Parameters

mediaUnit
VoxMediaUnitRequired
parameters
SendMediaParameters

sessionUpdate

Updates the session configuration. Send this before the first audio frame. turn_detection: null selects push-to-talk. https://docs.qwencloud.com/api-reference/qwen-audio-realtime/client-events#session-update

sessionUpdate(parameters: Object): void

Parameters

parameters
ObjectRequired

stopMediaTo

Stops sending media from Qwen Cloud (via WebSocket) to the media unit.

stopMediaTo(mediaUnit: VoxMediaUnit): void

Parameters

mediaUnit
VoxMediaUnitRequired

webSocketId

Returns the Qwen Cloud WebSocket id.

webSocketId(): string