File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,13 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
5151 client ??= new OpenAI ( { dangerouslyAllowBrowser } ) ;
5252
5353 if ( typeof ( client as any ) ?. _options ?. apiKey !== 'string' ) {
54- throw new Error ( 'Call the create method instead to construct the client' ) ;
54+ throw new Error (
55+ [
56+ 'Cannot open Realtime WebSocket with a function-based apiKey.' ,
57+ 'Use the factory so the key is resolved before connecting:' ,
58+ '- OpenAIRealtimeWebSocket.create(client, { model })' ,
59+ ] . join ( '\n' ) ,
60+ ) ;
5561 }
5662
5763 this . url = buildRealtimeURL ( client , props . model ) ;
Original file line number Diff line number Diff line change @@ -14,7 +14,13 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
1414 super ( ) ;
1515 client ??= new OpenAI ( ) ;
1616 if ( typeof ( client as any ) . _options . apiKey !== 'string' ) {
17- throw new Error ( 'Call the create method instead to construct the client' ) ;
17+ throw new Error (
18+ [
19+ 'Cannot open Realtime WebSocket with a function-based apiKey.' ,
20+ 'Use the factory so the key is resolved before connecting:' ,
21+ '- OpenAIRealtimeWS.create(client, { model })' ,
22+ ] . join ( '\n' ) ,
23+ ) ;
1824 }
1925 this . url = buildRealtimeURL ( client , props . model ) ;
2026 this . socket = new WS . WebSocket ( this . url , {
You can’t perform that action at this time.
0 commit comments