Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions examples/openai-realtime/ws-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ svc.on('session:new', (session) => {

session
.on('/event', (_evt: Record<string, any>) => {
// 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<string, any>) => {
const { name, args, tool_call_id } = evt;
Expand Down Expand Up @@ -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',
Expand All @@ -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' },
},
},
},
Expand Down
13 changes: 8 additions & 5 deletions jambonz/references/voice-ai-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')`
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
})
Expand Down