Skip to main content
This quickstart connects over WebSocket, sends a text message, and plays the model’s spoken reply through your speakers. One session does everything — the model listens and speaks natively, with no separate transcription or synthesis steps to manage.
Looking for an easier path? LiveKit and Pipecat have Higgs Realtime support built in and handle the WebSocket, audio, and interruption plumbing for you — often the fastest route to a production voice agent. Already running on OpenAI’s Realtime API? Migrate your existing integration with a few config changes. This page covers the raw WebSocket path — the best way to learn how the API actually works.

How it works

Your app holds a single WebSocket session and exchanges JSON events with the model: That’s the whole loop. When you stream microphone audio instead of text, turn detection makes the last step automatic — the model replies on its own when you stop speaking, no response.create needed.

Before you begin

You need:
  • A Boson API key stored in BOSON_API_KEY
  • Available credit — new accounts must claim their free trial credit before their first API call
  • Python 3.10 or later with the websockets and sounddevice packages
  • Speakers or headphones — the reply plays as audio
New to Boson AI? Set up your account walks through all of it.

Connect and play a reply

Connect, configure the session, send a text message, and play the model’s spoken reply:
You should hear the assistant speak its reply out loud, then see its transcript printed. The reply arrives as a stream of response.output_audio.delta events (base64 24 kHz 16-bit mono PCM) alongside response.output_audio_transcript.delta text, ending with response.done. To talk instead of type, stream microphone audio with input_audio_buffer.append — with server_vad turn detection the model detects when you stop speaking and responds on its own, no response.create needed.
Building for the browser or mobile? Don’t ship your API key: mint a short-lived key with POST /v1/realtime/client_secrets and connect with the bai-client-secret.<key> subprotocol (see Authentication).

It didn’t work?

sounddevice plays through your system’s default output device. Check that a working output device is selected and unmuted. The transcript print (Assistant: …) confirms the model replied even if playback failed.
Invalid API key (or an invalid/expired ephemeral key). Check BOSON_API_KEY is set in the shell running the script and matches a key in your workspace. See Authentication.
A billing refusal — your key is fine, but the account has no available balance. New accounts must claim their free trial credit first; otherwise add credits in workspace billing. See Common error types.

Go deeper

Connections & sessions

Session configuration, limits, and lifecycle.

Audio & voices

Audio formats, preset voices, and custom voices.

Turn detection & interruptions

server_vad, semantic_vad, and barge-in.

Tool calling

Let the model call your functions mid-conversation.

LiveKit & Pipecat

Production voice-agent frameworks with Higgs Realtime built in.

Migrate from OpenAI

The protocol is OpenAI Realtime compatible — most integrations move with config changes.