hello-realtime-video
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.
Viewing readonly version of main branch: v47View latest version
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is an OpenAI Realtime API application built with Deno and Val Town that supports WebRTC video/audio communication. The app is deployed at https://hello-realtime-video.val.run.
- Runtime: Deno (with Val Town platform)
- Framework: Hono (web framework)
- API: OpenAI Realtime API with WebRTC
- Frontend: Vanilla HTML/CSS/JavaScript
āāā frontend/
ā āāā index.html # Main UI with WebRTC client implementation
āāā routes/
ā āāā rtc.ts # WebRTC call management endpoint
ā āāā observer.ts # WebSocket observer for call monitoring
ā āāā utils.ts # Shared utilities and OpenAI configuration
āāā main.tsx # Main Hono app entry point
āāā deno.json # Deno configuration
āāā README.md
Required environment variable:
OPENAI_API_KEY
- OpenAI API key from platform.openai.com
# Run with Deno (requires network and env permissions) deno run --allow-net --allow-env main.tsx
# Lint all TypeScript/JavaScript files deno lint
# Type check without running deno check main.tsx
GET /
- Serves the main HTML frontendPOST /rtc
- Creates a new WebRTC call with OpenAI- Query param:
?video=true
enables video support
- Query param:
POST /observer/:callId
- Starts WebSocket observer for a call
- main.tsx: Hono application router that serves the frontend and routes API calls
- routes/rtc.ts: Handles WebRTC call creation via OpenAI's
/v1/realtime/calls
endpoint - routes/observer.ts: WebSocket connection for monitoring call status
- routes/utils.ts: Configuration for OpenAI API (model, voice, instructions)
- frontend/index.html: Complete WebRTC client implementation with video/audio UI
- Model:
gpt-realtime
- Voice:
marin
- Audio: Near-field noise reduction
- Video: Optional, enabled via query parameter
This project uses Val Town utilities for file serving:
import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
The application is deployed as a Val Town HTTP trigger with the entry point:
export default app.fetch;
- The app requires a valid OpenAI API key with access to the Realtime API
- WebRTC connections are established directly with OpenAI's servers
- The observer pattern allows monitoring of active calls
- Frontend handles all WebRTC negotiation and media streaming