API reference
Realtime
No model serves this yet
/v1/realtimeUse the Realtime endpoint when text and audio need to move over one persistent connection. It is protected by the same API key, key scope, model permissions, and rate limits as the HTTP API.
#Connect from your server
Open the WebSocket from a trusted server process and send Authorization: Bearer with the API key during the handshake. Do not expose a long-lived API key in browser JavaScript: browsers cannot safely attach this header and anyone can extract a shipped key.
import WebSocket from "ws";
const socket = new WebSocket("wss://YOUR_DOMAIN/v1/realtime", {
headers: { Authorization: "Bearer sk-YOUR_KEY" },
});
socket.on("open", () => {
// Send standard Realtime session and conversation events here.
});
socket.on("message", (event) => {
// Forward text / audio deltas to your client.
});#Session and event flow
After connecting, send the standard Realtime session and conversation events for the model you selected. Forward server events to your browser through your own short-lived channel; this keeps the platform key and the upstream WebSocket under your control.
1
Connect
Open one authenticated server-side socket.
2
Configure
Send session configuration and conversation input.
3
Relay
Forward deltas to your client and close the session when finished.
#Reconnect deliberately
A WebSocket is stateful. If the connection closes, create a new session and replay only the application state you intentionally retained. Treat 401, 403, 402, and 429 as actionable account or key signals; retry transient network and 5xx failures with bounded backoff.
Start with HTTP if you do not need live audio
Still stuck?
Send us the request ID or the error message and we will look into it.