OpenAI Live
Continuous voice conversations over the GPT-Live protocol with the OpenAI SDK.
wss://api.allmodels.io/oai/live/sessionsOpenAIAllModels serves the GPT-Live protocol for two models: openai/gpt-live-1 and gemini/gemini-3.8-live. Name the model in the first frame, session.start, not in the URL. Use an openai SDK version that includes LiveWS (JavaScript) or client.live.connect() (Python).
Start a session
Send session.start, stream microphone audio with session.input_audio.append, and play session.output_audio.delta. To end, send session.close and stop at session.closed.
import OpenAI from "openai";
import { LiveWS } from "openai/resources/live/ws";
const client = new OpenAI({
apiKey: process.env.ALLMODELS_API_KEY,
baseURL: "https://api.allmodels.io/oai"
});
const live = new LiveWS(client);
live.on("session.output_audio.delta", ({ delta }) => {
// Play Buffer.from(delta, "base64"): 24 kHz, 16-bit, mono PCM.
});
live.on("session.closed", ({ reason, usage }) => {
console.log(`closed: ${reason}, ${usage.seconds} s`);
live.close();
});
live.on("error", ({ error }) => console.error(error));
live.send({
type: "session.start",
session: {
model: "gpt-live-1", // or "gemini-3.8-live"
instructions: "You are a helpful voice assistant. Keep replies short.",
audio: {
format: { type: "audio/pcm", rate: 24000 },
output: { voice: "marin" } // for gemini-3.8-live, a Gemini voice such as "Zephyr"
},
delegation: { type: "client" }
}
});
// Stream microphone audio as session.input_audio.append, about every 100 ms.For a complete example that streams a recorded question and saves the spoken reply, see Speech to speech.
Answer delegations
When the model hands a task to your app, it sends session.delegation.created. Send progress with session.thinking.append, which the model hears but does not speak, and the answer with session.commentary.append, which it speaks. Use delegation.id as delegation_id.
live.on("session.delegation.created", async ({ delegation }) => {
live.send({ type: "session.thinking.append", delegation_id: delegation.id, content: "Checking the calendar." });
const answer = await checkCalendar(); // your code
live.send({ type: "session.commentary.append", delegation_id: delegation.id, content: answer });
});The event carries no task text: read the request from the conversation (session.input_transcript.delta).
Differences from OpenAI
- Client delegation only.
session.delegationmust be absent or{"type": "client"}. Responses and Decisions delegation, Decisiontriggersandstore: trueare refused with anerrorand close1008. - Unsupported events.
response.*anddecision.*client events are answered with anerror; the session stays open. - Correlation. Send
event_idon a client event to get it back asclient_event_idon its acknowledgement orerror. gemini-3.8-live:session.updateaccepts onlydelegation; other fields returnunknown_parameter.session.output_audio.fixture.playis not supported.session.instructions.appendandsession.thinking.appendneed a delegation id;nullis accepted only onsession.commentary.append.- The user's transcript arrives after they finish speaking, and the model waits for them to finish before it answers.
session.usage.updatedhas nocontext_window.
Events
| Direction | Events |
|---|---|
| Client → server | session.start, session.update, session.input_audio.append, session.input_audio.mute / .unmute, session.instructions.append, session.thinking.append, session.commentary.append, session.output_audio.fixture.play (gpt-live-1 only), session.close |
| Server → client | session.started, session.updated, session.input_audio.muted / .unmuted, session.instructions.appended, session.thinking.appended, session.commentary.appended, session.output_audio.fixture.playing / .played (gpt-live-1 only), session.output_audio.delta, session.input_transcript.delta, session.output_transcript.delta, session.delegation.created, session.usage.updated, session.closed, error |
Fields and examples for each event: client events and server events. Voices, audio formats and billing: Speech to speech.
