Recommended drop-in route is bare /v1/listen. Full detail in docs/DEEPGRAM_SDK_USAGE.md.
// Browser: cannot set Authorization header on a WebSocket, so pass the
// credential via the `token` subprotocol. Point at the bare host —
// the SDK appends /v1/listen.
const ws = new WebSocket("wss://stt.home.dudoxx.com/v1/listen",
["token", "any-dev-key"]);
ws.binaryType = "arraybuffer";
ws.onmessage = (e) => {
const f = JSON.parse(e.data);
if (f.type === "Results") {
const words = f.channel?.alternatives?.[0]?.words;
}
};// Node/SSR: real @deepgram/sdk with the Token header. Bare host base URL.
import { DeepgramClient } from "@deepgram/sdk";
const client = new DeepgramClient({
apiKey: "any-dev-key",
baseUrl: "wss://stt.home.dudoxx.com", // SDK appends /v1/listen
});
const socket = await client.listen.v1.connect({
model: "nova-2", language: "en", encoding: "linear16",
sample_rate: 16000, channels: 1, interim_results: true,
Authorization: "Token any-dev-key",
});socket.connect() gotcha// GOTCHA (@deepgram/sdk 5.x): the V1Socket from connect() is NOT connected
// until you call socket.connect(). Register handlers FIRST, then connect:
socket.on("open", () => { /* stream PCM via socket.sendMedia(buf) */ });
socket.on("message", (frame) => { /* Metadata | Results */ });
socket.on("close", () => {});
socket.connect();// PCM pacing: 16 kHz mono linear16. 3200-byte chunks (=100 ms) every
// ~50 ms so live VAD runs. After the last chunk wait ~1.5 s before
// CloseStream so the final Results frame is not raced away.