Realtime
OpenAI Realtime API–compatible voice WebSocket.
WS /v1/realtime transparently proxies OpenAI Realtime events. Server-to-server clients work by changing base URL and API key only.
Authentication#
Pass Authorization: Bearer $PLEUM_API_KEY or x-api-key on the handshake. Do not put the key in the query string.
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | query | Required | e.g. gpt-realtime-2.1, gpt-realtime-2.1-mini |
| Authorization | header | Required | Bearer $PLEUM_API_KEY or x-api-key |
Connection and session flow#
After the connection opens, configure the session with session.update (for example, output_modalities and audio.output.voice), then exchange Realtime events. Server events are relayed unchanged. The proxy aggregates response.done usage and settles when the connection closes.
Node.js example#
import WebSocket from "ws";
const model = "gpt-realtime-2.1";
const url = `wss://apirouter.pleum.ai/v1/realtime?model=${model}`;
const ws = new WebSocket(url, {
headers: {
Authorization: "Bearer " + process.env.PLEUM_API_KEY,
},
});
ws.on("open", () => {
ws.send(JSON.stringify({
type: "session.update",
session: {
type: "realtime",
output_modalities: ["audio"],
audio: {
output: { voice: "alloy" },
},
},
}));
});
ws.on("message", (data) => {
const event = JSON.parse(data.toString());
console.log(event.type);
});Connection errors and recovery#
1008: check the model, missing/invalid key, key permissions, or insufficient balance/budget. 1013: the request limit was reached; reduce call frequency before reconnecting. 1011: the upstream connection failed; wait a moment, then reconnect.Billing and limits#
Credits are held on connect and settled from response.done usage (text/audio tokens) when the session ends. A successful upstream session is billed at least 1 KRW, rounded up to a whole won.