This example shows how to combine Next.js with the OpenAI Agents SDK to create a realtime voice agent.
Set the OPENAI_API_KEY environment variable and run:
pnpm examples:realtime-nextOpen http://localhost:3000 in your browser and start talking.
/– WebRTC voice demo using theRealtimeSessionclass. Code insrc/app/page.tsx./websocket– Same agent over WebSockets. Code insrc/app/websocket/page.tsx./raw-client– Low-level WebRTC example usingOpenAIRealtimeWebRTC. Code insrc/app/raw-client/page.tsx.