Realtime voice and video conversation
MOSS-Live 1.0 is a full-duplex voice model built for natural, expressive realtime conversation. It listens while it speaks, supports natural interruptions, and delegates complex reasoning and long-running tasks to your own backend, continuing to talk with the user while they run. It also accepts realtime video streams, understands the conversation through both sound and image, and streams back voice and text.
/v1/realtimemoss-live-1.0Create an API Key
Create a key in API Key management and configure it in a server-side environment variable.
Environment variable MOSS_API_KEY=<your_api_key_here>Connect and authenticate
Connect with a server-side WebSocket client. Specify the model in the query parameter and pass the API Key in the handshake request header.
FieldTypeRequiredDescriptionModel ID. Use the stable ID; snapshot IDs are also supported. Pass it in the model query parameter of the WebSocket URL.
Bearer
<API Key>; only in the WebSocket handshake request header.Connection URL wss://api.mosi.cn/v1/realtime?model=moss-live-1.0 Authorization: Bearer $MOSS_API_KEYCreate a session
After connecting, first send this JSON text frame:
Create a session { "action": "attach_session", "session_id": null }After you receive
session_attached, savedata.session_id, then start sending audio. A basic conversation can use the default configuration; to set a persona, change the voice, add tools, or enable client delegation, configure them as described in the API reference.If you sent
session.update, wait forsession.updatedand confirm thatdata.erroris empty before enabling input. If connecting or configuring fails, handle the error first and do not keep sending media.Send realtime voice
Turn on the microphone first:
Turn on the microphone {"action":"mic_state","enabled":true}Capture audio, convert it to 16 kHz mono PCM S16LE without file headers, and send it continuously at realtime speed as WebSocket binary frames. Keep sending silent frames after the user stops speaking so the model can detect the pause.
Voice-only integrations send PCM directly in binary frames. In browser apps, the server relays audio and events, and the API Key is kept on the server. Keep capturing and sending microphone audio during playback.
Receive and display answers
The session keeps returning model speech, along with transcripts of the user's speech and the model's speech that you can show as captions or a conversation log. Play the returned speech in order and display either side's transcript as needed. Text events use
{"action":"event name","data":{…}}; audio arrives in separate WebSocket binary frames.Show captions and the conversation log
Event received What the app does input.transcript.updated/input.transcript.doneUpdate or confirm the user transcript with data.text.output.transcript.updated/output.transcript.doneUpdate or confirm the model transcript with data.text.data.textis the current full text: replace the displayed text on each update instead of appending. See the API reference for revisions to confirmed user transcripts and for the fields that link text to a reply.Play model speech
- When you receive
response.audio.started, get ready to receive audio for that reply. - Each
response.audio.contextcarries therun_id,turn_id, andchunk_idof the next binary audio message. Save them and play the 48 kHz mono PCM S16LE audio in the order received. - When a chunk has actually finished playing, send
playback.chunk.completedwith the samerun_id,turn_id, andchunk_id. - After you receive
response.audio.doneand all audio of that reply has actually finished playing, sendplayback.completed.
For example, after one audio chunk finishes playing, send:
Audio chunk finished playing { "action": "playback.chunk.completed", "run_id": "<received run_id>", "turn_id": "<received turn_id>", "chunk_id": "<received chunk_id>" }After the whole reply finishes playing, send:
Whole reply finished playing { "action": "playback.completed", "run_id": "<received run_id>", "turn_id": "<received turn_id>" }Playback acknowledgements are triggered by the player's actual playback progress; captions update independently from the text events.
- When you receive
Handle interruptions and keep talking
When the user speaks while the model is talking, keep sending audio. After you receive
response.audio.stop, immediately stop playback for thatrun_idandturn_id, clear its queued audio, and then sendplayback.stopped. Keep the connection open to receive the next reply.First acknowledge the chunks that finished playing, then report
played_audio_ms, the part of the current unfinished chunk that has played; use 0 if it has not started. See the API reference for the fields and how to calculate them.After you receive
response.interrupted, userun_idandturn_idto mark that reply as interrupted and finished, and clear its in-progress state. This event is the final state of that reply. Keep the connection, keep sending microphone audio, and receive the next reply; stop playback and sendplayback.stoppedfollowing the flow above.End the conversation
Close the WebSocket, stop microphone capture, clear queued audio, and release player resources. If video is enabled, stop camera or screen capture as well.
End the session ws.close(); stream?.getTracks().forEach(track => track.stop()); // Also stop the player and clear queued audio.Closing the connection ends the session. For billing information, see Pricing.
Verify the integration
- Say one sentence: you see the user transcript and hear the model's answer.
- Interrupt while the model is answering: the old reply stops playing and the model then responds to the new input.
- After a full reply plays normally, playback acknowledgements have been sent and you receive
output.transcript.doneandresponse.ended(data.status=completed). - After closing the conversation, the microphone, video capture, and player have all stopped.
Backend service setup
The backend service receives the complex reasoning and long-running tasks that MOSS-Live delegates, and sends progress and results back asynchronously. You can use the ready-made Pi integration or connect your own harness.
Option 1: Use Pi
Pi is already adapted: configure the backend model's provider, Base URL, model ID, and API Key to start using it. It requires Node.js 22.19.0 or later and supports macOS and Linux; Pi is installed with the dependencies.
Start Pi with the companion example and verify a conversation:
npx @mossai/mosslive@0.1.0 demoFollow the terminal prompts to finish the setup and enter your MOSS API Key and backend model key, then open the local address shown in the terminal to start a conversation. Settings are saved in moss-live.config.json; keys are entered at startup, or you can provide them through the MOSS_API_KEY and CUSTOMER_BACKEND_KEY environment variables.
By default the example enables only the read-only tools read / grep / find / ls; adjust permissions with pi.tools. To use Pi in an existing app, see the Pi integration example in the API reference.
Option 2: Connect your own harness
Use the same JavaScript SDK to connect your own harness and implement task execution, progress reporting, result delivery, and cancellation. You can start by generating an adapter project:
npx @mossai/mosslive@0.1.0 init-adapter --directory my-adapterThe project includes an executor template, AGENTS.md, and contract tests. After you complete the adapter by following the guide, attach the executor to the realtime connection. For the interfaces, see API reference: JavaScript SDK and executors.
Backend service setup is optional; realtime conversation and custom tools work on their own.