WSS
wss://api.modellix.ai/api/v1/live/google/gemini-3.1-flash-live-previewQuick Start
Installwebsockets>=14 and set the MODELLIX_API_KEY environment variable. This Python example sends a text question, prints the transcript, and saves the spoken reply to reply.wav.
Session Setup
Sendsetup as the first JSON message. The URL selects the model, so you can omit setup.model.
Choose
MINIMAL, LOW, MEDIUM, or HIGH. The default favors low latency. Higher levels let the model spend more time reasoning before it answers.Set to
{} to request resumption handles. To resume a session, connect to the same model from the same Modellix team and set handle to the latest saved value. An unrecognized handle closes the connection with code 1008. Reconnect without a handle to start a new session.Declare tools your application runs with
functionDeclarations. Omit Google Search. Requesting Google Search closes the connection with code 1008.Send Input
Wait forsetupComplete before sending any of these messages.
Send base64-encoded, 16-bit little-endian mono PCM in
data. For 16 kHz input, set mimeType to audio/pcm;rate=16000.Send base64-encoded JPEG or PNG frames in
data with the matching mimeType. Send at most one frame per second.Set
name to the function name and response to an object containing its result. Copy the matching call’s id when provided.Read the Reply
A server message can contain audio, transcription, and a turn marker together. Read the content before handling the turn marker.Decode each audio part’s base64
data and play the chunks in arrival order as mono 24 kHz, 16-bit little-endian PCM.The tools for your application to run. Each call identifies the function by
name and may include an id and args.When
sessionResumptionUpdate.resumable is true, save the latest non-empty handle for reconnection.