Skip to content

Commit fa6ccaf

Browse files
committed
Customizing realtime model
1 parent a5cb948 commit fa6ccaf

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class RealtimeAPI extends RealtimeEventHandler {
5656
* @param {{model?: string}} [settings]
5757
* @returns {Promise<true>}
5858
*/
59-
async connect({ model } = { model: 'gpt-4o-realtime-preview-2024-10-01' }) {
59+
async connect(model = "gpt-4o-realtime-preview-2024-10-01") {
6060
if (!this.apiKey && this.url === this.defaultUrl) {
6161
console.warn(`No apiKey provided for connection to "${this.url}"`);
6262
}

lib/client.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ export class RealtimeClient extends RealtimeEventHandler {
197197
modalities: ['text', 'audio'],
198198
instructions: '',
199199
voice: 'verse',
200+
model: 'gpt-4o-realtime-preview-2024-10-01',
200201
input_audio_format: 'pcm16',
201202
output_audio_format: 'pcm16',
202203
input_audio_transcription: null,
@@ -393,8 +394,8 @@ export class RealtimeClient extends RealtimeEventHandler {
393394
if (this.isConnected()) {
394395
throw new Error(`Already connected, use .disconnect() first`);
395396
}
396-
await this.realtime.connect();
397397
this.updateSession();
398+
await this.realtime.connect(this.sessionConfig?.model);
398399
return true;
399400
}
400401

@@ -485,6 +486,7 @@ export class RealtimeClient extends RealtimeEventHandler {
485486
modalities = void 0,
486487
instructions = void 0,
487488
voice = void 0,
489+
model = void 0,
488490
input_audio_format = void 0,
489491
output_audio_format = void 0,
490492
input_audio_transcription = void 0,
@@ -497,6 +499,7 @@ export class RealtimeClient extends RealtimeEventHandler {
497499
modalities !== void 0 && (this.sessionConfig.modalities = modalities);
498500
instructions !== void 0 && (this.sessionConfig.instructions = instructions);
499501
voice !== void 0 && (this.sessionConfig.voice = voice);
502+
model !== void 0 && (this.sessionConfig.model = model);
500503
input_audio_format !== void 0 &&
501504
(this.sessionConfig.input_audio_format = input_audio_format);
502505
output_audio_format !== void 0 &&

0 commit comments

Comments
 (0)