> For a complete documentation index, fetch https://docs.voximplant.ai/llms.txt

# Deepgram

Deepgram provides a VoxEngine client for connecting a call or media unit to the Deepgram Voice Agent API over WebSocket.

Use `Deepgram.createVoiceAgentClient(...)` to create a `VoiceAgentClient` for the current scenario.

## Related guides

Learn how Deepgram Voice Agent fits into a VoxEngine call flow.

## Contents

* &#x20;[Usage](#usage): required module import and basic flow.
* &#x20;[Factory functions](#factory-functions): create the Deepgram Voice Agent client.
* &#x20;[Methods](#methods): media and conversation control methods.
* &#x20;[Events](#events): WebSocket media bridge events.
* &#x20;[VoiceAgentEvents](#voiceagentevents): Deepgram Voice Agent event names and payload fields.

## Usage

Add the module before using the namespace:

```js
require(Modules.Deepgram);
```

Create the client, bridge media, and listen for Voice Agent events.

## Factory functions

### &#x20;createVoiceAgentClient

Creates a [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.

```ts
createVoiceAgentClient(parameters: VoiceAgentClientParameters): Promise<VoiceAgentClient>
```

**Parameters**

| Parameter    | Type                                                  | Req. | Description |
| ------------ | ----------------------------------------------------- | ---- | ----------- |
| `parameters` | <code>VoiceAgent<wbr />Client<wbr />Parameters</code> | ✓    |             |

**Returns**

| Type                                    | Description                                                                |
| --------------------------------------- | -------------------------------------------------------------------------- |
| <code>Promise\<VoiceAgentClient></code> | Resolves to the [`Deepgram.VoiceAgentClient`](#voiceagentclient) instance. |

## VoiceAgentClient

## Methods

### &#x20;addEventListener

Adds a handler for the specified [Deepgram.VoiceAgentEvents](/api-reference/voxengine/deepgram#voiceagentevents) or [Deepgram.Events](/api-reference/voxengine/deepgram#events) event. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called.

```ts
addEventListener(event: Events | VoiceAgentEvents | string, callback: (event: object) => any): void
```

**Parameters**

| Parameter  | Type                                                     | Req. | Description                                   |
| ---------- | -------------------------------------------------------- | ---- | --------------------------------------------- |
| `event`    | <code>Events \| VoiceAgent<wbr />Events \| string</code> | ✓    | Event constant or event name to subscribe to. |
| `callback` | <code>(event: object) => any</code>                      | ✓    | Function called when the event is emitted.    |

**Returns**

| Type   | Description              |
| ------ | ------------------------ |
| `void` | Does not return a value. |

### &#x20;clearMediaBuffer

Clears the VoiceAgent WebSocket media buffer.

```ts
clearMediaBuffer(parameters?: ClearMediaBufferParameters): void
```

**Parameters**

| Parameter    | Type                                                  | Req. | Description |
| ------------ | ----------------------------------------------------- | ---- | ----------- |
| `parameters` | <code>ClearMedia<wbr />Buffer<wbr />Parameters</code> | ✗    |             |

**Returns**

| Type   | Description              |
| ------ | ------------------------ |
| `void` | Does not return a value. |

### &#x20;close

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

```ts
close(): void
```

**Parameters**

This method does not accept parameters.

**Returns**

| Type   | Description              |
| ------ | ------------------------ |
| `void` | Does not return a value. |

### &#x20;id

Returns the VoiceAgentClient id.

```ts
id(): string
```

**Parameters**

This method does not accept parameters.

**Returns**

| Type     | Description                 |
| -------- | --------------------------- |
| `string` | The requested string value. |

### &#x20;removeEventListener

Removes a handler for the specified [Deepgram.VoiceAgentEvents](/api-reference/voxengine/deepgram#voiceagentevents) or [Deepgram.Events](/api-reference/voxengine/deepgram#events) event.

```ts
removeEventListener(event: Events | VoiceAgentEvents | string, callback?: (event: object) => any): void
```

**Parameters**

| Parameter  | Type                                                     | Req. | Description                                   |
| ---------- | -------------------------------------------------------- | ---- | --------------------------------------------- |
| `event`    | <code>Events \| VoiceAgent<wbr />Events \| string</code> | ✓    | Event constant or event name to subscribe to. |
| `callback` | <code>(event: object) => any</code>                      | ✗    | Function called when the event is emitted.    |

**Returns**

| Type   | Description              |
| ------ | ------------------------ |
| `void` | Does not return a value. |

### &#x20;sendFunctionCallResponse

Send a message to provide a function call response in the middle of a conversation.
[https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1SendFunctionCallResponse](https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1SendFunctionCallResponse)

```ts
sendFunctionCallResponse(input: Object): void
```

**Parameters**

| Parameter | Type     | Req. | Description |
| --------- | -------- | ---- | ----------- |
| `input`   | `Object` | ✓    |             |

**Returns**

| Type   | Description              |
| ------ | ------------------------ |
| `void` | Does not return a value. |

### &#x20;sendInjectAgentMessage

Send a message to immediately trigger an Agent statement.
[https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1InjectAgentMessage](https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1InjectAgentMessage)

```ts
sendInjectAgentMessage(input: Object): void
```

**Parameters**

| Parameter | Type     | Req. | Description |
| --------- | -------- | ---- | ----------- |
| `input`   | `Object` | ✓    |             |

**Returns**

| Type   | Description              |
| ------ | ------------------------ |
| `void` | Does not return a value. |

### &#x20;sendInjectUserMessage

Send a text based message to the agent.
[https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1InjectUserMessage](https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1InjectUserMessage)

```ts
sendInjectUserMessage(input: Object): void
```

**Parameters**

| Parameter | Type     | Req. | Description |
| --------- | -------- | ---- | ----------- |
| `input`   | `Object` | ✓    |             |

**Returns**

| Type   | Description              |
| ------ | ------------------------ |
| `void` | Does not return a value. |

### &#x20;sendMediaTo

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

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

**Parameters**

| Parameter    | Type                                    | Req. | Description |
| ------------ | --------------------------------------- | ---- | ----------- |
| `mediaUnit`  | `VoxMediaUnit`                          | ✓    |             |
| `parameters` | <code>SendMedia<wbr />Parameters</code> | ✗    |             |

**Returns**

| Type   | Description              |
| ------ | ------------------------ |
| `void` | Does not return a value. |

### &#x20;sendUpdatePrompt

Send a message to update the system prompt of the agent.
[https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1UpdatePrompt](https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1UpdatePrompt)

```ts
sendUpdatePrompt(input: Object): void
```

**Parameters**

| Parameter | Type     | Req. | Description |
| --------- | -------- | ---- | ----------- |
| `input`   | `Object` | ✓    |             |

**Returns**

| Type   | Description              |
| ------ | ------------------------ |
| `void` | Does not return a value. |

### &#x20;sendUpdateSpeak

Send a message to change the Speak model in the middle of a conversation.
[https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1UpdateSpeak](https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1UpdateSpeak)

```ts
sendUpdateSpeak(input: Object): void
```

**Parameters**

| Parameter | Type     | Req. | Description |
| --------- | -------- | ---- | ----------- |
| `input`   | `Object` | ✓    |             |

**Returns**

| Type   | Description              |
| ------ | ------------------------ |
| `void` | Does not return a value. |

### &#x20;stopMediaTo

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

```ts
stopMediaTo(mediaUnit: VoxMediaUnit): void
```

**Parameters**

| Parameter   | Type           | Req. | Description |
| ----------- | -------------- | ---- | ----------- |
| `mediaUnit` | `VoxMediaUnit` | ✓    |             |

**Returns**

| Type   | Description              |
| ------ | ------------------------ |
| `void` | Does not return a value. |

### &#x20;webSocketId

Returns the VoiceAgent WebSocket id.

```ts
webSocketId(): string
```

**Parameters**

This method does not accept parameters.

**Returns**

| Type     | Description                 |
| -------- | --------------------------- |
| `string` | The requested string value. |

## Events

These events describe audio received through the Deepgram WebSocket media bridge.

### &#x20;WebSocketMediaStarted

Triggered when the audio stream sent by a third party through a Deepgram WebSocket is started playing.

Event constant: `Events.WebSocketMediaStarted`

**Payload**

| Field                                | Type                                     | Req. | Description                                                                                                                                       |
| ------------------------------------ | ---------------------------------------- | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`                             | <code>VoiceAgent<wbr />Client</code>     | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                     |
| `tag`                                | `string`                                 | ✗    | Special tag to name audio streams sent over one WebSocket connection. With it, one can send 2 audios to 2 different media units at the same time. |
| `encoding`                           | `string`                                 | ✗    | Audio encoding formats.                                                                                                                           |
| <code>custom<wbr />Parameters</code> | <code>\{ \[key: string]: string }</code> | ✗    | Custom parameters.                                                                                                                                |

### &#x20;WebSocketMediaEnded

Triggers after the end of the audio stream sent by a third party through a Deepgram WebSocket (**1 second of silence**).

Event constant: `Events.WebSocketMediaEnded`

**Payload**

| Field       | Type                                   | Req. | Description                                                                                                                                       |
| ----------- | -------------------------------------- | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`    | <code>VoiceAgent<wbr />Client</code>   | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                     |
| `tag`       | `string`                               | ✗    | Special tag to name audio streams sent over one WebSocket connection. With it, one can send 2 audios to 2 different media units at the same time. |
| `mediaInfo` | <code>WebSocket<wbr />MediaInfo</code> | ✗    | Information about the audio stream that can be obtained after the stream stops or pauses (**1 second of silence**).                               |

## VoiceAgentEvents

These events mirror server messages from the Deepgram Voice Agent API. The `data` field contains the provider event payload.

<a id="-unknown" />

The unknown event.

Event constant: `VoiceAgentEvents.Unknown`

**Payload**

| Field    | Type                                 | Req. | Description                                                                                                                                                                   |
| -------- | ------------------------------------ | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client` | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                 |
| `data`   | `Object`                             | ✗    | This event payload is provider-specific. See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent) for the full payload shape. |

<a id="-httpresponse" />

The HTTP response event.

Event constant: `VoiceAgentEvents.HTTPResponse`

**Payload**

| Field    | Type                                 | Req. | Description                                                                                   |
| -------- | ------------------------------------ | ---- | --------------------------------------------------------------------------------------------- |
| `client` | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance. |
| `data`   | `Object`                             | ✗    | The event's data.                                                                             |

<a id="-welcome" />

Receive a welcome message from the server to confirm the websocket has opened. [https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1Welcome](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1Welcome)

Event constant: `VoiceAgentEvents.Welcome`

**Payload**

| Field             | Type                                 | Req. | Description                                                                                                                                                                              |
| ----------------- | ------------------------------------ | ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`          | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                            |
| `data`            | `Object`                             | ✗    | Receive welcome message from Deepgram's Voice Agent API See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1Welcome). |
| `data.type`       | `"Welcome"`                          | ✓    | Message type identifier for welcome message                                                                                                                                              |
| `data.request_id` | `string`                             | ✓    | Unique identifier for the request                                                                                                                                                        |

Example `data`:

```json
{
  "type": "Welcome"
}
```

<a id="-settingsapplied" />

Confirms the server has successfully received and applied the Settings message. [https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1SettingsApplied](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1SettingsApplied)

Event constant: `VoiceAgentEvents.SettingsApplied`

**Payload**

| Field       | Type                                  | Req. | Description                                                                                                                                                                                               |
| ----------- | ------------------------------------- | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`    | <code>VoiceAgent<wbr />Client</code>  | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                                             |
| `data`      | `Object`                              | ✗    | Receive settings applied message from Deepgram's Voice Agent API See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1SettingsApplied). |
| `data.type` | <code>"Settings<wbr />Applied"</code> | ✓    | Message type identifier for settings applied confirmation                                                                                                                                                 |

Example `data`:

```json
{
  "type": "SettingsApplied"
}
```

<a id="-conversationtext" />

Facilitates real-time communication by relaying spoken statements from both the user and the agent. [https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1ConversationText](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1ConversationText)

Event constant: `VoiceAgentEvents.ConversationText`

**Payload**

| Field                   | Type                                   | Req. | Description                                                                                                                                                                                         |
| ----------------------- | -------------------------------------- | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`                | <code>VoiceAgent<wbr />Client</code>   | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                                       |
| `data`                  | `Object`                               | ✗    | Receive conversation text from Deepgram's Voice Agent API See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1ConversationText). |
| `data.type`             | <code>"Conversation<wbr />Text"</code> | ✓    | Message type identifier for conversation text                                                                                                                                                       |
| `data.role`             | `unknown`                              | ✓    | Identifies who spoke the statement                                                                                                                                                                  |
| `data.content`          | `string`                               | ✓    | The actual statement that was spoken                                                                                                                                                                |
| `data.languages_hinted` | `string[]`                             | ✓    | The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi. Optional.                                              |
| `data.languages`        | `string[]`                             | ✓    | Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi. Optional.                               |

Example `data`:

```json
{
  "type": "ConversationText"
}
```

<a id="-userstartedspeaking" />

Notifies the client that the user has begun speaking. [https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1UserStartedSpeaking](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1UserStartedSpeaking)

Event constant: `VoiceAgentEvents.UserStartedSpeaking`

**Payload**

| Field       | Type                                      | Req. | Description                                                                                                                                                                                                        |
| ----------- | ----------------------------------------- | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `client`    | <code>VoiceAgent<wbr />Client</code>      | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                                                      |
| `data`      | `Object`                                  | ✗    | Receive user started speaking message from Deepgram's Voice Agent API See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1UserStartedSpeaking). |
| `data.type` | <code>"UserStarted<wbr />Speaking"</code> | ✓    | Message type identifier indicating that the user has begun speaking                                                                                                                                                |

Example `data`:

```json
{
  "type": "UserStartedSpeaking"
}
```

<a id="-agentthinking" />

Informs the client when the agent is processing information. [https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1AgentThinking](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1AgentThinking)

Event constant: `VoiceAgentEvents.AgentThinking`

**Payload**

| Field          | Type                                 | Req. | Description                                                                                                                                                                                           |
| -------------- | ------------------------------------ | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`       | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                                         |
| `data`         | `Object`                             | ✗    | Receive agent thinking message from Deepgram's Voice Agent API See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1AgentThinking). |
| `data.type`    | <code>"Agent<wbr />Thinking"</code>  | ✓    | Message type identifier for agent thinking                                                                                                                                                            |
| `data.content` | `string`                             | ✓    | The text of the agent's thought process                                                                                                                                                               |

Example `data`:

```json
{
  "type": "AgentThinking"
}
```

<a id="-functioncallrequest" />

Server-initiated message requesting a function call, to be handled by either client or server. [https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1FunctionCallRequest](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1FunctionCallRequest)

Event constant: `VoiceAgentEvents.FunctionCallRequest`

**Payload**

| Field            | Type                                      | Req. | Description                                                                                                                                                                                                |
| ---------------- | ----------------------------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`         | <code>VoiceAgent<wbr />Client</code>      | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                                              |
| `data`           | `Object`                                  | ✗    | Receive function call request from Deepgram's Voice Agent API See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1FunctionCallRequest). |
| `data.type`      | <code>"Function<wbr />CallRequest"</code> | ✓    | Message type identifier for function call requests                                                                                                                                                         |
| `data.functions` | `unknown[]`                               | ✓    | Array of functions to be called                                                                                                                                                                            |

Example `data`:

```json
{
  "type": "FunctionCallRequest"
}
```

<a id="-functioncallresponse" />

Message containing the result of a function call, sent by client or server. [https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1ReceiveFunctionCallResponse](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1ReceiveFunctionCallResponse)

Event constant: `VoiceAgentEvents.FunctionCallResponse`

**Payload**

| Field    | Type                                 | Req. | Description                                                                                   |
| -------- | ------------------------------------ | ---- | --------------------------------------------------------------------------------------------- |
| `client` | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance. |
| `data`   | `Object`                             | ✗    | The event's data.                                                                             |

<a id="-promptupdated" />

Confirms that a Prompt Configuration change has been applied. [https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1PromptUpdated](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1PromptUpdated)

Event constant: `VoiceAgentEvents.PromptUpdated`

**Payload**

| Field       | Type                                 | Req. | Description                                                                                                                                                                                  |
| ----------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`    | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                                |
| `data`      | `Object`                             | ✗    | Receive prompt update from Deepgram's Voice Agent API See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1PromptUpdated). |
| `data.type` | <code>"Prompt<wbr />Updated"</code>  | ✓    | Message type identifier for prompt update confirmation                                                                                                                                       |

Example `data`:

```json
{
  "type": "PromptUpdated"
}
```

<a id="-speakupdated" />

Confirms that a Speak Configuration change has been applied. [https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1SpeakUpdated](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1SpeakUpdated)

Event constant: `VoiceAgentEvents.SpeakUpdated`

**Payload**

| Field       | Type                                 | Req. | Description                                                                                                                                                                                |
| ----------- | ------------------------------------ | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `client`    | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                              |
| `data`      | `Object`                             | ✗    | Receive speak update from Deepgram's Voice Agent API See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1SpeakUpdated). |
| `data.type` | <code>"Speak<wbr />Updated"</code>   | ✓    | Message type identifier for speak update confirmation                                                                                                                                      |

Example `data`:

```json
{
  "type": "SpeakUpdated"
}
```

<a id="-agentaudiodone" />

Get signals that the server has finished sending the final audio segment to the client. [https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1AgentAudioDone](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1AgentAudioDone)

Event constant: `VoiceAgentEvents.AgentAudioDone`

**Payload**

| Field       | Type                                 | Req. | Description                                                                                                                                                                                              |
| ----------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`    | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                                            |
| `data`      | `Object`                             | ✗    | Receive agent audio done message from Deepgram's Voice Agent API See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1AgentAudioDone). |
| `data.type` | <code>"AgentAudio<wbr />Done"</code> | ✓    | Message type identifier indicating the agent has finished sending audio                                                                                                                                  |

Example `data`:

```json
{
  "type": "AgentAudioDone"
}
```

<a id="-error" />

Receive errors from the server if an issue has occurred. [https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1Error](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1Error)

Event constant: `VoiceAgentEvents.Error`

**Payload**

| Field              | Type                                 | Req. | Description                                                                                                                                                                           |
| ------------------ | ------------------------------------ | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`           | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                         |
| `data`             | `Object`                             | ✗    | Receive error response from Deepgram's Voice Agent API See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1Error). |
| `data.type`        | `unknown`                            | ✓    | Message type identifier for error responses                                                                                                                                           |
| `data.description` | `string`                             | ✓    | A description of what went wrong                                                                                                                                                      |
| `data.code`        | `string`                             | ✓    | Error code identifying the type of error                                                                                                                                              |

Example `data`:

```json
{
  "type": "Error"
}
```

<a id="-warning" />

Receive warnings from the server if an issue has occurred. [https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1Warning](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1Warning)

Event constant: `VoiceAgentEvents.Warning`

**Payload**

| Field              | Type                                 | Req. | Description                                                                                                                                                                               |
| ------------------ | ------------------------------------ | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`           | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                             |
| `data`             | `Object`                             | ✗    | Receive warning messages from Deepgram's Voice Agent API See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1Warning). |
| `data.type`        | `unknown`                            | ✓    | Message type identifier for warnings                                                                                                                                                      |
| `data.description` | `string`                             | ✓    | Description of the warning                                                                                                                                                                |
| `data.code`        | `string`                             | ✓    | Warning code identifier                                                                                                                                                                   |

Example `data`:

```json
{
  "type": "Warning"
}
```

<a id="-history" />

Provide conversation and function call history when starting a new Voice Agent session. [https://developers.deepgram.com/docs/voice-agent-history](https://developers.deepgram.com/docs/voice-agent-history)

Event constant: `VoiceAgentEvents.History`

**Payload**

| Field       | Type                                 | Req. | Description                                                                                                                                                                                                                                                                                                                         |
| ----------- | ------------------------------------ | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`    | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance.                                                                                                                                                                                                                                       |
| `data`      | `Object`                             | ✗    | Receive a conversation history message from Deepgram's Voice Agent API. Each message is either a conversation text (with role and content) or a function call record (with function\_calls array). See the [partner event documentation](https://developers.deepgram.com/reference/voice-agent/voice-agent#receive.AgentV1History). |
| `data.type` | `string`                             | ✓    | Event type identifier.                                                                                                                                                                                                                                                                                                              |

Example `data`:

```json
{
  "type": "History"
}
```

<a id="-websocketerror" />

The WebSocket error response event.

Event constant: `VoiceAgentEvents.WebSocketError`

**Payload**

| Field    | Type                                 | Req. | Description                                                                                   |
| -------- | ------------------------------------ | ---- | --------------------------------------------------------------------------------------------- |
| `client` | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance. |
| `data`   | `Object`                             | ✗    | The event's data.                                                                             |

<a id="-connectorinformation" />

Contains information about connector.

Event constant: `VoiceAgentEvents.ConnectorInformation`

**Payload**

| Field    | Type                                 | Req. | Description                                                                                   |
| -------- | ------------------------------------ | ---- | --------------------------------------------------------------------------------------------- |
| `client` | <code>VoiceAgent<wbr />Client</code> | ✓    | The [Deepgram.VoiceAgentClient](/api-reference/voxengine/deepgram#voiceagentclient) instance. |
| `data`   | `Object`                             | ✗    | The event's data.                                                                             |