Skip to main content
Build a browser-based voice agent that streams audio to the Inworld Realtime API using WebSocket.
The WebSocket transport is best for server-side and proxied connections where you can set custom headers. For browser-native voice with lower latency, see the WebRTC Quickstart.

Get Started

1

Create an API key

Create an Inworld account.In Inworld Portal, generate an API key by going to Settings > API Keys. Copy the Base64 credentials.Set your API key as an environment variable.
2

Create the server

Create server.js. It proxies WebSocket events between the browser and Inworld, configures the voice session, and triggers an initial greeting.
server.js
3

Create the frontend

Create index.html in the same directory. It captures microphone audio, plays agent audio, and displays transcripts that fade after each turn.
index.html
4

Install and run

Open http://localhost:3000 and click Start Conversation. The agent greets you with audio.

How It Works

Key events used:
  • input_audio_buffer.append — streams mic audio to Inworld
  • response.output_audio.delta — agent audio chunks for playback
  • input_audio_buffer.speech_started — triggers interruption (stops agent playback)

Next Steps

WebSocket reference

Full connection details, session config, and event handling.

Model configuration

Configure the key elements of your voice agent.