websocket.d.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { AzureOpenAI, OpenAI } from "../index.js";
  2. import type { RealtimeClientEvent } from "../resources/realtime/realtime.js";
  3. import { OpenAIRealtimeEmitter } from "./internal-base.js";
  4. type _WebSocket = typeof globalThis extends ({
  5. WebSocket: infer ws extends abstract new (...args: any) => any;
  6. }) ? InstanceType<ws> : any;
  7. export declare class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
  8. url: URL;
  9. socket: _WebSocket;
  10. constructor(props: {
  11. model: string;
  12. dangerouslyAllowBrowser?: boolean;
  13. /**
  14. * Callback to mutate the URL, needed for Azure.
  15. * @internal
  16. */
  17. onURL?: (url: URL) => void;
  18. /** Indicates the token was resolved by the factory just before connecting. @internal */
  19. __resolvedApiKey?: boolean;
  20. }, client?: Pick<OpenAI, 'apiKey' | 'baseURL'>);
  21. static create(client: Pick<OpenAI, 'apiKey' | 'baseURL' | '_callApiKey'>, props: {
  22. model: string;
  23. dangerouslyAllowBrowser?: boolean;
  24. }): Promise<OpenAIRealtimeWebSocket>;
  25. static azure(client: Pick<AzureOpenAI, '_callApiKey' | 'apiVersion' | 'apiKey' | 'baseURL' | 'deploymentName'>, options?: {
  26. deploymentName?: string;
  27. dangerouslyAllowBrowser?: boolean;
  28. }): Promise<OpenAIRealtimeWebSocket>;
  29. send(event: RealtimeClientEvent): void;
  30. close(props?: {
  31. code: number;
  32. reason: string;
  33. }): void;
  34. }
  35. export {};
  36. //# sourceMappingURL=websocket.d.ts.map