Console

Realtime video understanding

WSS/v1/realtime

Continuously send image frames and questions over WebSocket and receive incremental text events. This is a visual understanding protocol, incompatible with audio Realtime, and is not SSE.

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: stringRequired

Model ID. Pass a stable or snapshot ID in the WebSocket connection's model query parameter

Authorization: HTTP headerRequired

Bearer <API Key>; query parameters and WebSocket subprotocols are not supported for authentication

Session flow

StageClientServer events and checks
ConnectComplete the WebSocket handshakeReceive session.created; the connection automatically creates a session
ConfigureSend session.configure exactly onceReceive session.configured and wait for session.ready
Send an imageSend input.frame JSON followed by image binary dataWait for input.frame.ready before sending binary data; wait for input.frame.accepted before sending the next input. Frames alone do not automatically generate answers
Ask a questionSend input.prompt separatelyNo need to attach the image again; receive accepted / processed, and possibly text, silence, or interruption events
Continue or finishContinue sending frames, set final=true, or send session.abortresponse.done ends one answer segment; session.done ends the session

Client events

FieldTypeDescription
session.configure: event

Send exactly once after connecting, within session.created.configure_timeout_s.

input.frame: event

Send image frame metadata; immediately send the complete image binary data after receiving input.frame.ready.

input.prompt: event

Send a question separately. The field is prompt, not text; the question uses the most recently received scene.

session.abort: event

End the entire session. This event does not consume seq_no and accepts no other fields.

Server events

FieldTypeDescription
Session events: server events

Determine connection, configuration, readiness, and the final session state.

Input events: server events

Determine whether frames or questions are ready to receive, submitted, or processed.

Output events: server events

Read incremental text and determine whether an answer segment is silent, interrupted, or complete.

Usage events: server events

Read observational usage and cumulative usage for an answer or session.

Error events: server events

Handle protocol or service failures.

Protocol limits

ItemCurrent protocol value and description
Control eventsEach event defaults to at most 256 KiB; calculated separately from image binary size
Configuration and deliveryConfigure within the server deadline; deliver binary data within 10 seconds after input.frame.ready, or the server sends an error event with code=session_timeout and ends the session
Input queueDefaults to 4, configurable range [1, 256]; unprocessed input capacity, not concurrent sessions
Context and durationWhichever is reached first: the returned context_limit or the session duration limit

Error codes

For authentication, permissions, rate limiting, and general HTTP errors during connection, see Error Codes. The following are protocol errors specific to realtime video understanding.

Error codesTriggerAction
invalid_requestInvalid client event/fields/order or oversized messageCorrect and resend; reconnect if disconnected
context_exhaustedSession context limit reachedEnd the session and create a new one
session_timeoutSession duration or idle limit reached, or binary data not delivered within 10 seconds after input.frame.readyCheck session activity and server limits; reconnect if needed
response_failedModel generation or processing failedRecord the error and decide whether to retry for your use case
session_capacity_exceededRealtime session capacity exhaustedReduce concurrency or retry later

Connection closure

Close codeMeaningClient action
1000Closed after the server sent session.done; sessions that ended with an error event also use this codeEnd the session without retrying; judge success by session.done.reason (such as completed, aborted, error) and any preceding error event
1001Service shutdown or connection leavingReconnect as required by your use case
1002Protocol errorCheck event format and send order before retrying
1009Binary data exceeds limits or control event is too large; an invalid_request error event may precede closure.Reduce message size and reconnect
1011Server failureRetry later and record the error
1013Service temporarily unable to processReduce concurrency and retry later