Live voice in apps and websites
Talk to an agent in real time from a browser or a mobile app with a single-use voice-session token.
Talk to an agent in real time over a WebSocket: microphone audio in, the agent's voice out, with barge-in and live transcripts. Sessions are billed per started minute like phone calls (under 5 seconds is free) and capped at 30 minutes.
1. Mint a voice-session token on your server#
The client must never hold your secret key. Your server mints a token right before each session (key with agents.write):
curl -X POST https://api.voicemint.io/api/v1/agents/AGENT_ID/live-sessions \
-H "Authorization: Bearer $VOICEMINT_API_KEY" -H "Content-Type: application/json" \
-d '{"variables": {"name": "Asha"}}'
# -> {"ws_url": "wss://.../api/v1/agents/AGENT_ID/live", "token": "vm_lst_...", "expires_in": 60, "subprotocol": "voicemint.live"}The token opens one session within 60 seconds, only for that agent, and stops working if the key is revoked first. Authenticate your own user on this endpoint: each session spends your credits. For a Meet: POST /meet/meets/{meet_id}/live-sessions (meet.write).
2. Connect from the client#
Pick your platform. Each SDK handles the microphone, echo cancellation, playback, barge-in and the protocol.
val session = VoiceMintSession.fromLiveSession(this, token = minted.token, wsUrl = minted.wsUrl)
lifecycleScope.launch { session.events.collect { e -> if (e is VoiceMintEvent.Transcript) show(e.role, e.text) } }
session.start()On a website, use the web widget or open the socket yourself:
const ws = new WebSocket(session.ws_url, ['voicemint.live', session.token]);
ws.binaryType = 'arraybuffer';
ws.onmessage = (e) => (typeof e.data === 'string' ? handle(JSON.parse(e.data)) : playPcm16(e.data, 24000));
// send microphone audio as 16-bit PCM, 16 kHz, mono ArrayBuffers: ws.send(chunk)From your server#
A server can also connect directly with the secret key in the handshake (Authorization: Bearer vm_sk_...) to wss://api.voicemint.io/api/v1/agents/{agent_id}/live.
Protocol#
| Direction | Frame | Meaning |
|---|---|---|
| client → server | binary | microphone audio, 16-bit PCM, 16 kHz, mono (about 100 ms chunks) |
| client → server | {"type":"text","text":"…"} | typed input |
| client → server | {"type":"stop"} | end the session |
| server → client | {"type":"ready", "sample_rate_in":16000, "sample_rate_out":24000, …} | start streaming |
| server → client | binary | agent audio, 16-bit PCM, 24 kHz, mono |
| server → client | {"type":"interrupted"} | the user barged in: drop queued playback |
| server → client | {"type":"transcript","role":"…","text":"…","is_final":true} | live transcript of either side |
| server → client | {"type":"error","message":"…"} | shown to the user; usually followed by a close |
Close codes: 4401 bad, used or expired token or key · 4402 not enough credits or the key's spend cap · 4403 no permission, IP not allowed or wrong agent · 4404 agent not found · 4429 rate limited or capacity full (retry shortly).