Console

Create a realtime conversation

WSS/v1/realtime

Establish a continuous two-way realtime session over WebSocket, stream in voice, camera, or screen frames, and receive streamed text and voice responses.

Connection and authentication

Upgrade an HTTP GET request to WebSocket. Connect to wss://api.mosi.cn/v1/realtime with the model query parameter specifying the model; place the API Key only in the Authorization request header.

FieldTypeRequiredDescription
model: query stringRequired

Model ID. Always moss-live-1.0, passed in the model query parameter of the WebSocket URL.

user: query stringOptional

Your own stable end-user ID, URL-encoded. Required when memory_scope=user; use the same user when reconnecting. Example: wss://api.mosi.cn/v1/realtime?model=moss-live-1.0&user=customer_001.

Authorization: HTTP headerRequired

Bearer <API Key>; put it in the Authorization request header of the WebSocket handshake.

Session flow

StageClientServer events and checks
ConnectComplete the WebSocket handshakeJoin the session after the connection opens
ConfigureSend attach_session, then session.updateWait for session_attached and then session.updated, and confirm data.error is an empty string
Send audio and videoEnable the microphone; for frames, enable media.mode and video.stateThe same connection receives audio and JPEG frames
AnswerDisplay text, play voice, and send playback acknowledgementsReceive input.transcript.done, output.transcript.done, and response.ended
Continue or endKeep sending input, or close the WebSocketThe connection can continue after a turn completes; closing the connection ends the session

Client events

FieldTypeDescription
attach_session: event

Joins the session; billing by online duration starts once session_attached is received.

session.update: event

Sets the persona and business rules; after receiving session.updated, check data.error. A non-empty value means the configuration did not take effect.

mic_state: event

Turns microphone input on or off.

media.mode: event

Enables tagged-v1 before video or screen sharing.

video.state: event

Controls camera or screen frames; turning frames off does not end the session.

playback.chunk.completed: event

Sent after each audio chunk has actually finished playing; put the fields at the top level of the message, not inside data. Acknowledge only audio that has actually finished playing, and do not wait for the answer text to finish before acknowledging.

playback.completed: event

Sent after receiving response.audio.done and finishing playback of all audio in the turn.

video.stream_focus: event

Sets the primary frame source to focus on.

playback.stopped: event

Sent after stopping the corresponding playback on response.audio.stop.

Server events

FieldTypeDescription
session_attached: event

The session has been joined; configure the persona and business rules after receiving it.

session.updated: event

Configuration result; enable media and the microphone when data.error is an empty string.

input.transcript.updated: event

User transcript update; data.text is the current full text, so replace the displayed text instead of appending each update.

input.transcript.done: event

User transcript completed.

output.transcript.updated: event

Model answer text update; data.text is the current full text, so replace the displayed text instead of appending each update.

output.transcript.done: event

Model answer text completed.

response.interrupted: event

The answer was interrupted; mark the matching answer as interrupted by run_id and turn_id.

response.audio.context: event

Save the audio context and pair it in order with the following binary audio.

response.audio.done: event

All audio for this turn has been sent; send playback.completed after playback has actually finished.

response.ended: event

Status notification for this turn; it does not mean the session has ended.

error: event

Error event; record the cause and release the connection and media resources.

response.audio.stop: event

Stop the corresponding voice playback and send playback.stopped.

Protocol limits

ItemCurrent protocol value and description
Audio16 kHz upstream and 48 kHz downstream, mono PCM S16LE; no WAV header. Keep sending silence after the user stops speaking.
Media framingtagged-v1: audio 0x00, camera JPEG 0x01, screen JPEG 0x02; audio keeps the prefix after frames are turned off.
FramesOne binary message per JPEG; no Base64, and complete MP4 files or H.264 streams are not accepted.
TransportAudio and frames share the same WebSocket.
Frame processingUnder load, the latest frame may be kept and pending older frames dropped; per-frame analysis is not guaranteed. 1 FPS, JPEG quality 0.8, a 640 px long edge for the camera, and 1024 px for the screen are client defaults, not hard limits.

Error codes

For authentication, permissions, rate limiting, and general HTTP errors during connection, see Error Codes. The following are protocol errors specific to the MOSS-LIVE endpoint.

Error codesTriggerAction
memory_scope_requires_userThe user memory scope lacks an end-user identityPass a stable user, or use the session scope.
memory_scope_immutableCreation options changed on reconnectReconnect with the options used at creation; create a new session to change them.
invalid_memory_scopeInvalid parameter valueCheck the enum values.