/* Note that in client-side environments like web browsers, we recommend using WebRTC instead. It is possible, however, to use the standard WebSocket interface in browser-like environments like Deno and Cloudflare Workers. */ const ws = new WebSocket( "wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-12-17", [ "realtime", // Auth "openai-insecure-api-key." + OPENAI_API_KEY, // Optional "openai-organization." + OPENAI_ORG_ID, "openai-project." + OPENAI_PROJECT_ID, // Beta protocol, required "openai-beta.realtime-v1" ] ); ws.on("open", function open() { console.log("Connected to server."); }); ws.on("message", function incoming(message) { console.log(message.data); });