Skip to main content
GET
/
ws
/
stream
Streams audio to the speech service via WebSocket.
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>"
Use this API to stream audio to the speech service via WebSocket connection. To stream audio, you must first establish an authenticated WebSocket connection. The authentication method you use depends on your client type.

Browser Clients

If you are connecting from a browser, you must use the 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>
The server will then negotiate and select this protocol to establish the connection.

Non-Browser Clients

If you are connecting from a non-browser client, such as a mobile or server-side application, you must provide the token and session ID as separate HTTP headers in the initial WebSocket upgrade request.
  • sdp_suki_token: Your Suki token.
  • ambient_session_id: The ID for the current session.

Code Examples

  • Python
  • TypeScript
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()

Headers

Sec-WebSocket-Protocol
string
sdp_suki_token
string
required
ambient_session_id
string
required

Response