export type GetApiOpenaiV1RealtimeArgs = {model?: string | undefined, deployment?: string | undefined, Upgrade: 'websocket', 'Sec-WebSocket-Protocol'?: string | undefined}; export type GetApiOpenaiV1RealtimeOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * WebSocket Realtime (OpenAI alias) * * GET /openai/v1/realtime * * Also accepts auth: BasicAuth, VirtualKeyAuth, ApiKeyAuth */ export const getApiOpenaiV1Realtime = async (args: GetApiOpenaiV1RealtimeArgs, options?: GetApiOpenaiV1RealtimeOptions) => { const {baseUrl = "http://localhost:8080", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.model != null) query.append("model", String(args.model)) if (args.deployment != null) query.append("deployment", String(args.deployment)) if (args.Upgrade != null) headers.set("Upgrade", String(args.Upgrade)) if (args['Sec-WebSocket-Protocol'] != null) headers.set("Sec-WebSocket-Protocol", String(args['Sec-WebSocket-Protocol'])) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/openai/v1/realtime${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };