You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Stream audio directly via WebSockets for bidirectional real-time communication
3
+
description: Stream audio directly via WebSockets for real-time, bidirectional communication
4
4
slug: calls/websocket-transport
5
5
---
6
6
7
7
# WebSocket Transport
8
8
9
-
Vapi's WebSocket transport provides a powerful way to establish direct, bidirectional audio communication between your application and Vapi's AI assistants. Unlike traditional phone or web calls, this transport mechanism allows you to send and receive raw audio data in real time with minimal latency.
9
+
Vapi's WebSocket transport enables real-time, bidirectional audio communication directly between your application and Vapi's AI assistants. Unlike traditional phone or web calls, this transport method lets you stream raw audio data instantly with minimal latency.
10
10
11
-
## Overview
11
+
## Key Benefits
12
12
13
-
The WebSocket transport offers several advantages:
14
-
15
-
-**Low Latency**: Direct streaming reduces processing delays
16
-
-**Bidirectional Communication**: Simultaneous audio streaming in both directions
17
-
-**Flexible Integration**: Implement in any environment that supports WebSockets
18
-
-**Customizable Audio Format**: Configure sample rate and format to match your needs
19
-
-**Sample Rate Conversion**: Automatic handling of different audio sample rates
13
+
-**Low Latency**: Direct streaming ensures minimal delays.
14
+
-**Bidirectional Streaming**: Real-time audio flow in both directions.
15
+
-**Easy Integration**: Compatible with any environment supporting WebSockets.
16
+
-**Flexible Audio Formats**: Customize audio parameters such as sample rate.
17
+
-**Automatic Sample Rate Conversion**: Seamlessly handles various audio rates.
|`container`| Audio container format |`raw` (Raw PCM)|
67
+
|`sampleRate`| Sample rate in Hz |`16000` (16kHz)|
72
68
73
69
<Important>
74
-
Currently, only raw PCM audio data (`pcm_s16le`format with `raw` container) is supported. Additional audio formats and container types may be supported in future releases.
70
+
Currently, Vapi supports only raw PCM (`pcm_s16le` with `raw` container). Additional formats may be supported in future updates.
75
71
</Important>
76
72
77
73
<Note>
78
-
Vapi automatically handles sample rate conversion between your specified rate and the model's required format. This means you can send audio at 8kHz, 44.1kHz, or other rates, and Vapi will convert it appropriately.
74
+
Vapi automatically converts sample rates as needed. You can stream audio at 8kHz, 44.1kHz, etc., and Vapi will handle conversions seamlessly.
79
75
</Note>
80
76
81
77
## Connecting to the WebSocket
82
78
83
-
After creating a call, connect to the WebSocket URL returned in the response:
79
+
Use the WebSocket URL from the response to establish a connection:
| Replaces phone/web as transport | Supplements existing calls |
179
+
|Uses `provider: "vapi.websocket"`| Accessed via `monitor.listenUrl`|
202
180
203
-
See [Live Call Control](/calls/call-features) for more information about the Call Listen feature.
181
+
Refer to [Live Call Control](/calls/call-features) for more on the Call Listen feature.
204
182
205
183
<Warning>
206
-
When using the WebSocket transport, you cannot simultaneously use phone number parameters (`phoneNumber` or `phoneNumberId`). The transport method is mutually exclusive with phone-based calling.
207
-
</Warning>
184
+
When using WebSocket transport, phone-based parameters (`phoneNumber` or `phoneNumberId`) are not permitted. These methods are mutually exclusive.
0 commit comments