Skip to main content

create-simli-app-openai

A Next.js app that talks to OpenAI’s Realtime API over WebRTC and speaks the answers through a Simli avatar.
The browser sends your microphone to OpenAI’s Realtime API over WebRTC, and plays the voice that comes back through the avatar with the JavaScript SDK. Both API keys stay on the server:
  • /api/simli-token creates the Simli session token.
  • /api/openai-session creates the OpenAI call for the browser’s WebRTC offer and returns only the answer. The model, voice and prompt are set on the server, in app/avatar.ts, and the server hangs up the call when the session’s time is up.
To run it, copy .env.example, fill in SIMLI_API_KEY and OPENAI_API_KEY, then run npm install and npm run dev. The README has the details, including how to change the face, voice and prompt.
In production, both routes return 403 until you put them behind your own sign-in, because anyone who can call them starts a session on your Simli and OpenAI accounts. See the README’s “Before you deploy”. The server-side hang-up needs a long-running server; on serverless hosts, see the README.
For an OpenAI agent that runs on a server instead, see LiveKit Agents or Pipecat.