Public
Like
14
hello-realtime
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data β all from the browser, and deployed in milliseconds.
main.tsx
https://jubertioai--0198a962fcd377e89abe4d2fa0914f2f.web.val.run
Hello Realtime is a OpenAI Realtime app that supports both WebRTC and SIP (telephone) users. You can access the app via WebRTC at hello-realtime.val.run, or via SIP by calling 425-800-0042.
This demo shows off the new SIP API, the new all-in-one WebRTC API, and the new server-side websocket interface.
If you remix the app, you'll just need to pop in your own OPENAI_API_KEY
(from
platform.openai.com), and if you want SIP, the
OPENAI_SIGNING_SECRET
.
- WebRTC Flow:
- Browser connects to frontend
- creates WebRTC offer
/rtc
endpoint handles SDP negotiation with OpenAI- observer established to monitor session
- SIP Flow:
- Phone calls triggers webhook
/sip
endpoint verifies webhook and accepts call- observer established to monitor session
GET /
- serves the WebRTC-based appPOST /rtc
- creates a new WebRTC-based Realtime API session- Supports optional
model
URL parameter to override the default model - Example:
POST /rtc?model=gpt-4o-realtime-preview
- Supports optional
POST /sip
- handles an incoming Realtime API SIP callPOST /observer
- internal endpoint to establish a Realtime API websocket for session control
βββ frontend/
β βββ index.html # HTML/JS application for WebRTC
βββ main.tsx # Main entrypoint for the val.town app
βββ routes/
|
βββ agent.ts # Realtime API session configuration and tools
βββ observer.ts # Server-side session control for SIP & WebRTC
βββ rtc.ts # WebRTC session setup
βββ sip.ts # SIP webhook handling and session setup
βββ utils.ts # Various HTTP helpers