Skip to main content

Voice Conversation

Establish a WebSocket connection for voice conversation.

Note: This is a WebSocket endpoint, requiring wss:// protocol connection.

Connection URL example:

wss://api-platform.ope.ai/v1/realtime?model=AudioLLM/Voice2.0

Try It

GET/v1/realtimewss://api-platform.ope.ai/v1/realtime

Authentication

Uses Bearer Token authentication.

  • Header: Authorization: Bearer <token>
  • Example: Authorization: Bearer sk-xxxxxx

Browser native WebSocket API cannot customize request headers; if your server only supports Header authentication, please use server-side/Node client (or let the gateway support passing token via query).

Query parameters

ParameterTypeRequiredDescription
modelstringNoModel to use (example: AudioLLM/Voice2.0)

Request examples

// npm i ws
import WebSocket from "ws";

const url = "wss://api-platform.ope.ai/v1/realtime?model=AudioLLM/Voice2.0";
const apiKey = process.env.OPEAI_API_KEY;

const ws = new WebSocket(url, {
headers: {
Authorization: `Bearer ${apiKey}`,
},
});

ws.on("open", () => {
console.log("connected");
// Send first packet/event according to your server protocol
// ws.send(JSON.stringify({ type: "input_text", text: "hello" }));
});

ws.on("message", (data) => {
console.log("message:", data.toString());
});

ws.on("close", () => console.log("closed"));
ws.on("error", (e) => console.error("error:", e));

Response example

  • 101: Switching Protocols (WebSocket handshake successful)
  • 400: Parameter/authentication error (returns JSON error object)