MCPcopy Index your code
hub / github.com/cameronking4/openai-realtime-api-nextjs

github.com/cameronking4/openai-realtime-api-nextjs @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
119 symbols 483 edges 86 files 16 documented · 13%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

OpenAI WebRTC Shadcn Next15 Starter

This is a WebRTC-based Voice AI stream application using OpenAI's Realtime API and WebRTC. Project contains /api route and UI components developed with Next.js and shadcn/ui. It supports real-time audio conversations implented in skrivov/openai-voice-webrtc-next with the addition of a hook to abstract the WebRTC handling.

https://github.com/user-attachments/assets/ea9324af-5c18-48d2-b980-2b81baeea4c0

Features

  • Next.js Framework: Built with Next.js for server-side rendering and API routes.
  • Modern UI: Animated using Tailwind CSS & Framer Motion & shadcn/ui.
  • Use-WebRTC Hook: A hook to abstract the OpenAI WebRTC handling.
  • Tool Calling: 6 example functions to demonstrate client side tools along with Realtime API: getCurrentTime, partyMode, changeBackground, launchWebsite, copyToClipboard, scrapeWebsite (requires FireCrawl API key)
  • Localization: Select language for app strings and the voice agent (English, Spanish, French, Chinese)
  • Type Safety: TypeScript with strict eslint rules (optional)

Requirements

  • Deno runtime or Node.js
  • OpenAI API Key or Azure OpenAI API Key in .env file

Installation

1. Clone the Repository

git clone https://github.com/cameronking4/openai-realtime-api-nextjs.git
cd openai-realtime-api-nextjs

2. Environment Setup

Create a .env file in the root directory:

OPENAI_API_KEY=your-openai-api-key

3. Install Dependencies

If using Node.js:

npm install

If using Deno:

deno install

4. Run the Application

Using Node.js:

npm run dev

Using Deno:

deno task start

The application will be available at http://localhost:3000.

Usage

  1. Open the app in your browser: http://localhost:3000.
  2. Select a voice and start the audio session.

Deploy to Vercel

Deploy in one-click

Deploy with Vercel

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

Extension points exported contracts — how you extend this code

UseWebRTCAudioSessionReturn (Interface)
* The return type for the hook, matching Approach A * (RefObject for the audioIndicatorRef).
hooks/use-webrtc.ts
Message (Interface)
(no doc)
types/index.ts
TextInputProps (Interface)
(no doc)
components/text-input.tsx
TokenUsageDisplayProps (Interface)
(no doc)
components/token-usage.tsx
VoiceSelectorProps (Interface)
(no doc)
components/voice-select.tsx
BroadcastButtonProps (Interface)
(no doc)
components/broadcast-button.tsx
StatusDisplayProps (Interface)
(no doc)
components/status.tsx
TranscriberProps (Interface)
(no doc)
components/ui/transcriber.tsx

Core symbols most depended-on inside this repo

cn
called by 197
lib/utils.ts
t
called by 72
components/translations-context.tsx
useTranslations
called by 16
components/translations-context.tsx
dispatch
called by 5
hooks/use-toast.ts
updateEphemeralUserMessage
called by 5
hooks/use-webrtc.ts
useCarousel
called by 4
components/ui/carousel.tsx
useSidebar
called by 4
components/ui/sidebar.tsx
useFormField
called by 4
components/ui/form.tsx

Shape

Function 102
Interface 17

Languages

TypeScript100%

Modules by API surface

hooks/use-webrtc.ts17 symbols
hooks/use-tools.ts12 symbols
hooks/use-toast.ts9 symbols
components/ui/pagination.tsx5 symbols
components/ui/transcriber.tsx4 symbols
components/ui/sheet.tsx3 symbols
components/ui/drawer.tsx3 symbols
components/ui/confetti.tsx3 symbols
components/ui/chart.tsx3 symbols
components/translations-context.tsx3 symbols
components/text-input.tsx3 symbols
hooks/use-mobile.tsx2 symbols

For agents

$ claude mcp add openai-realtime-api-nextjs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact