diff --git a/examples/openai-realtime/ws-app.ts b/examples/openai-realtime/ws-app.ts index 5f87c42..28d0e97 100644 --- a/examples/openai-realtime/ws-app.ts +++ b/examples/openai-realtime/ws-app.ts @@ -30,7 +30,7 @@ svc.on('session:new', (session) => { session .on('/event', (_evt: Record) => { - // OpenAI Realtime events (conversation.item.*, response.audio_transcript.done, etc.) + // OpenAI Realtime events (conversation.item.*, response.output_audio_transcript.done, etc.) }) .on('/toolCall', async (evt: Record) => { const { name, args, tool_call_id } = evt; @@ -78,26 +78,25 @@ svc.on('session:new', (session) => { .answer() .pause({ length: 1 }) .openai_s2s({ - model: 'gpt-4o-realtime-preview-2024-12-17', + model: 'gpt-realtime-2.1', auth: { apiKey }, actionHook: '/final', eventHook: '/event', toolHook: '/toolCall', events: [ 'conversation.item.*', - 'response.audio_transcript.done', + 'response.output_audio_transcript.done', 'input_audio_buffer.committed', ], llmOptions: { response_create: { - modalities: ['text', 'audio'], - instructions: 'Please assist the user with their request.', - voice: 'alloy', - output_audio_format: 'pcm16', - temperature: 0.8, + output_modalities: ['audio'], + instructions: 'Greet the caller and ask how you can help.', max_output_tokens: 4096, }, session_update: { + type: 'realtime', + instructions: 'Please assist the user with their request.', tools: [ { name: 'get_weather', @@ -114,12 +113,17 @@ svc.on('session:new', (session) => { }, ], tool_choice: 'auto', - input_audio_transcription: { model: 'whisper-1' }, - turn_detection: { - type: 'server_vad', - threshold: 0.8, - prefix_padding_ms: 300, - silence_duration_ms: 500, + audio: { + input: { + transcription: { model: 'gpt-live-transcribe' }, + turn_detection: { + type: 'server_vad', + threshold: 0.8, + prefix_padding_ms: 300, + silence_duration_ms: 500, + }, + }, + output: { voice: 'alloy' }, }, }, }, diff --git a/jambonz/references/voice-ai-guide.md b/jambonz/references/voice-ai-guide.md index 3b032a9..2ddebb2 100644 --- a/jambonz/references/voice-ai-guide.md +++ b/jambonz/references/voice-ai-guide.md @@ -30,7 +30,8 @@ The agent verb has three main configuration blocks: `recognizer` (STT), `llm` (t ### OpenAI (`openai_s2s`) -- Supports `model` (e.g. `gpt-4o-realtime-preview`) and `llmOptions.messages` for system prompt +- Supports `model` (default `gpt-realtime-2.1`; also `gpt-realtime-2.1-mini`). `llmOptions` carries `session_update` (persona `instructions`, tools, audio) and `response_create` (the first response) +- `gpt-realtime` and `gpt-realtime-mini` shut down on 2027-01-20; the `gpt-4o-realtime-preview*` models are already gone - Function calling via `toolHook` - Events via `eventHook` - Look up full schema: `get_jambonz_schema('openai_s2s')` @@ -96,9 +97,10 @@ session.on('/tool-call', (evt) => { session .openai_s2s({ - model: 'gpt-4o-realtime-preview', + model: 'gpt-realtime-2.1', llmOptions: { - messages: [{ role: 'system', content: 'You are a helpful assistant.' }], + session_update: { type: 'realtime', instructions: 'You are a helpful assistant.' }, + response_create: {}, }, toolHook: '/tool-call', actionHook: '/s2s-done', @@ -157,9 +159,10 @@ session.on('tts:user_interrupt', () => { ```typescript session .openai_s2s({ - model: 'gpt-4o-realtime-preview', + model: 'gpt-realtime-2.1', llmOptions: { - messages: [{ role: 'system', content: 'You are a friendly customer support agent.' }], + session_update: { type: 'realtime', instructions: 'You are a friendly customer support agent.' }, + response_create: {}, }, actionHook: '/done', })