Rate this page:

VoiceAgentAPIClient

Constructors

constructor
Copy URL

Methods

addEventListener
Copy URL
addEventListener(event: 

Events

|

VoiceAgentAPIEvents

,
callback:

Function

):

void

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

Parameters

Returns

  • type:

    void

clearMediaBuffer
Copy URL
clearMediaBuffer(parameters: 

ClearMediaBufferParameters

):

void

Clears the XAI WebSocket media buffer.

Parameters

Returns

  • type:

    void

close
Copy URL
close(): 

void

Closes the XAI connection (over WebSocket) or connection attempt.

Returns

  • type:

    void

conversationItemCreate
Copy URL
conversationItemCreate(parameters: 

Object

):

void

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

conversationItemDelete
Copy URL
conversationItemDelete(parameters: 

Object

):

void

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

conversationItemTruncate
Copy URL
conversationItemTruncate(parameters: 

Object

):

void

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

id
Copy URL
id(): 

string

Returns the VoiceAgentAPIClient id.

Returns

  • type:

    string

inputAudioBufferClear
Copy URL
inputAudioBufferClear(parameters: 

Object

):

void

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

inputAudioBufferCommit
Copy URL
inputAudioBufferCommit(parameters: 

Object

):

void

Commit the input audio buffer as a user message. Only available when turn_detection type is null. https://docs.x.ai/developers/rest-api-reference/inference/voice#input_audio_buffer.commit

Parameters

  • parameters:

    Object

    Optional

    Optional. Event parameters

Returns

  • type:

    void

removeEventListener
Copy URL
removeEventListener(event: 

Events

|

VoiceAgentAPIEvents

,
callback:

Function

):

void

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

Parameters

Returns

  • type:

    void

responseCancel
Copy URL
responseCancel(parameters: 

Object

):

void

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

responseCreate
Copy URL
responseCreate(parameters: 

Object

):

void

Request the server to create a new assistant response when using client side vad. (This is handled automatically when using server side vad.) Prefer nested { response: { ... } } body per xAI docs; flat fields are also accepted by the connector. https://docs.x.ai/developers/rest-api-reference/inference/voice#response.create

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

sendMediaTo
Copy URL
sendMediaTo(mediaUnit: 

VoxMediaUnit

,
parameters:

SendMediaParameters

):

void

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

Parameters

Returns

  • type:

    void

sessionUpdate
Copy URL
sessionUpdate(parameters: 

Object

):

void

Send this event to update the session’s configuration. https://docs.x.ai/developers/rest-api-reference/inference/voice#session.update

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

stopMediaTo
Copy URL
stopMediaTo(mediaUnit: 

VoxMediaUnit

):

void

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

Parameters

Returns

  • type:

    void

webSocketId
Copy URL
webSocketId(): 

string

Returns the XAI WebSocket id.

Returns

  • type:

    string

Rate this page: