@@ -189,15 +189,14 @@ import { RealtimeUtils } from './utils.js';
189189export class RealtimeClient extends RealtimeEventHandler {
190190 /**
191191 * Create a new RealtimeClient instance
192- * @param {{url?: string, apiKey?: string, dangerouslyAllowAPIKeyInBrowser?: boolean, debug?: boolean} } [settings]
192+ * @param {{url?: string, apiKey?: string, model?: string, dangerouslyAllowAPIKeyInBrowser?: boolean, debug?: boolean} } [settings]
193193 */
194- constructor ( { url, apiKey, dangerouslyAllowAPIKeyInBrowser, debug } = { } ) {
194+ constructor ( { url, apiKey, model = 'gpt-4o-realtime-preview-2024-10-01' , dangerouslyAllowAPIKeyInBrowser, debug } = { } ) {
195195 super ( ) ;
196196 this . defaultSessionConfig = {
197197 modalities : [ 'text' , 'audio' ] ,
198198 instructions : '' ,
199199 voice : 'verse' ,
200- model : 'gpt-4o-realtime-preview-2024-10-01' ,
201200 input_audio_format : 'pcm16' ,
202201 output_audio_format : 'pcm16' ,
203202 input_audio_transcription : null ,
@@ -207,6 +206,7 @@ export class RealtimeClient extends RealtimeEventHandler {
207206 temperature : 0.8 ,
208207 max_response_output_tokens : 4096 ,
209208 } ;
209+ this . realtimeModel = model ;
210210 this . sessionConfig = { } ;
211211 this . transcriptionModels = [
212212 {
@@ -394,8 +394,8 @@ export class RealtimeClient extends RealtimeEventHandler {
394394 if ( this . isConnected ( ) ) {
395395 throw new Error ( `Already connected, use .disconnect() first` ) ;
396396 }
397+ await this . realtime . connect ( this . realtimeModel ) ;
397398 this . updateSession ( ) ;
398- await this . realtime . connect ( this . sessionConfig ?. model ) ;
399399 return true ;
400400 }
401401
@@ -486,7 +486,6 @@ export class RealtimeClient extends RealtimeEventHandler {
486486 modalities = void 0 ,
487487 instructions = void 0 ,
488488 voice = void 0 ,
489- model = void 0 ,
490489 input_audio_format = void 0 ,
491490 output_audio_format = void 0 ,
492491 input_audio_transcription = void 0 ,
@@ -499,7 +498,6 @@ export class RealtimeClient extends RealtimeEventHandler {
499498 modalities !== void 0 && ( this . sessionConfig . modalities = modalities ) ;
500499 instructions !== void 0 && ( this . sessionConfig . instructions = instructions ) ;
501500 voice !== void 0 && ( this . sessionConfig . voice = voice ) ;
502- model !== void 0 && ( this . sessionConfig . model = model ) ;
503501 input_audio_format !== void 0 &&
504502 ( this . sessionConfig . input_audio_format = input_audio_format ) ;
505503 output_audio_format !== void 0 &&
0 commit comments