Realtime voice API
wss://moses-ai.com/tts/realtime
A WebSocket for LLM token streams. Send text deltas as they arrive and get raw PCM (24 kHz, 16-bit, mono) back, plus events for each spoken segment. Cancel any time for barge-in, warm up a voice before the answer starts, change voice or language per message.
# pip install websockets
async with websockets.connect(
"wss://moses-ai.com/tts/realtime",
additional_headers={"Authorization": "Bearer mk_…"}) as ws:
await ws.send(json.dumps({"type": "config", "voice": "alba"}))
async for delta in llm_stream(): # your model's tokens
await ws.send(json.dumps({"type": "text", "text": delta}))
await ws.send(json.dumps({"type": "end"}))
async for msg in ws: # PCM chunks + events
...