Dave M
CDCloudflare Developers
•Created by Dave M on 1/14/2025 in #workers-help
Connect via WebSocket connection to OpenAI Realtime API - wss://api.openai.com/v1/realtime
I watched @Craig 's YT video connecting WebRTC to the OpenAI Realtime API. Exciting stuff!
However, I tried my own Worker solution and was not as successful.
Why? Cloudflare workers does not support NPM WS library. Why can't I just use the Worker-supported WebSocket class? Well, because the OpenAI realtime API requires HTTP header
Authorization : Bearer $OAI_API_KEY
On OAI Realtime API Docs page, they just added this code to establish vanilla javascript WebSocket connection. Thank the higher powers! I was stuck on this for a week!! 🤪
4 replies