curl --request GET \
--url https://sdp.suki-stage.com/ws/stream \
--header 'ambient_session_id: <ambient_session_id>' \
--header 'sdp_suki_token: <sdp_suki_token>'"<string>"WebSocket endpoint for real-time audio streaming during ambient sessions
curl --request GET \
--url https://sdp.suki-stage.com/ws/stream \
--header 'ambient_session_id: <ambient_session_id>' \
--header 'sdp_suki_token: <sdp_suki_token>'"<string>"Sec-WebSocket-Protocol header during the WebSocket handshake.
The header must specify the SukiAmbientAuth protocol, followed by the session ID and the token in the following format:
Sec-WebSocket-Protocol: SukiAmbientAuth,<ambient_session_id>,<sdp_suki_token>
sdp_suki_token: Your Suki token.
ambient_session_id: The ID for the current session.
import websocket
import json
ambient_session_id = "123dfg-456dfg-789dfg-012dfg"
token = "<sdp_suki_token>"
# For non-browser clients, use headers
ws_url = f"wss://sdp.suki.ai/ws/stream"
# Create WebSocket connection with headers
ws = websocket.create_connection(
ws_url,
header=[
f"sdp_suki_token: {token}",
f"ambient_session_id: {ambient_session_id}"
]
)
try:
# Send audio chunks
with open("audio.wav", "rb") as audio_file:
chunk = audio_file.read(1024)
while chunk:
ws.send_binary(chunk)
chunk = audio_file.read(1024)
# Signal end of stream
ws.send(json.dumps({"type": "end_of_stream"}))
# Receive responses
while True:
try:
result = ws.recv()
print(f"Received: {result}")
except websocket.WebSocketConnectionClosedException:
break
finally:
ws.close()
// Browser client example
const ambientSessionId = '123dfg-456dfg-789dfg-012dfg';
const token = '<sdp_suki_token>';
// For browser clients, use Sec-WebSocket-Protocol header
const ws = new WebSocket('wss://sdp.suki.ai/ws/stream', [
`SukiAmbientAuth,${ambientSessionId},${token}`
]);
ws.onopen = () => {
console.log('WebSocket connection opened');
// Send audio chunks (example with FileReader)
const audioFile = document.getElementById('audioFile').files[0];
const reader = new FileReader();
reader.onload = (e) => {
const arrayBuffer = e.target.result;
const chunkSize = 1024;
for (let i = 0; i < arrayBuffer.byteLength; i += chunkSize) {
const chunk = arrayBuffer.slice(i, i + chunkSize);
ws.send(chunk);
}
// Signal end of stream
ws.send(JSON.stringify({ type: 'end_of_stream' }));
};
reader.readAsArrayBuffer(audioFile);
};
ws.onmessage = (event) => {
console.log('Received:', event.data);
};
ws.onerror = (error) => {
console.error('WebSocket error:', error);
};
ws.onclose = () => {
console.log('WebSocket connection closed');
};
Required FOR BROWSER CLIENTS ONLY. Sent during WebSocket handshake. Format: 'SukiAmbientAuth <ambient_session_id> <sdp_suki_token>'
Required FOR NON-BROWSER CLIENTS ONLY: The SDP Suki token. Sent as a standard header with the initial upgrade request.
Required FOR NON-BROWSER CLIENTS ONLY: The ambient session ID. Sent as a standard header with the initial upgrade request.
Switching Protocols - Indicates successful WebSocket handshake." // Standard successful WS upgrade response
The response is of type string.