From 03d4fa28caee9ccc67275d585ec49d1dcf1fca50 Mon Sep 17 00:00:00 2001 From: Forrest Blount Date: Wed, 11 Mar 2026 20:53:12 +0000 Subject: [PATCH] voice-call: thread OpenAI API key through config instead of process.env RealtimeCallHandler now accepts the pre-resolved key from config.streaming.openaiApiKey (passed at construction time in runtime.ts), matching the pattern used by the streaming webhook path. Falls back to OPENAI_API_KEY env if not set in config, same as streaming. Co-Authored-By: Claude Sonnet 4.6 --- extensions/voice-call/src/runtime.ts | 1 + extensions/voice-call/src/webhook/realtime-handler.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/voice-call/src/runtime.ts b/extensions/voice-call/src/runtime.ts index 4069fa3e493..7bad25ee984 100644 --- a/extensions/voice-call/src/runtime.ts +++ b/extensions/voice-call/src/runtime.ts @@ -179,6 +179,7 @@ export async function createVoiceCallRuntime(params: { manager, provider, coreConfig, + config.streaming.openaiApiKey, ); webhookServer.setRealtimeHandler(realtimeHandler); log.info("[voice-call] Realtime voice handler initialized"); diff --git a/extensions/voice-call/src/webhook/realtime-handler.ts b/extensions/voice-call/src/webhook/realtime-handler.ts index 7fd426b7c79..0d409abdd17 100644 --- a/extensions/voice-call/src/webhook/realtime-handler.ts +++ b/extensions/voice-call/src/webhook/realtime-handler.ts @@ -36,6 +36,8 @@ export class RealtimeCallHandler { private manager: CallManager, private provider: VoiceCallProvider, private coreConfig: CoreConfig | null, + /** Pre-resolved OpenAI API key (falls back to OPENAI_API_KEY env at call time) */ + private openaiApiKey?: string, ) {} /** @@ -129,9 +131,9 @@ export class RealtimeCallHandler { callSid: string, ws: WebSocket, ): OpenAIRealtimeVoiceBridge | null { - const apiKey = process.env.OPENAI_API_KEY; + const apiKey = this.openaiApiKey ?? process.env.OPENAI_API_KEY; if (!apiKey) { - console.error("[voice-call] No OPENAI_API_KEY for realtime call"); + console.error("[voice-call] No OpenAI API key for realtime call (set streaming.openaiApiKey or OPENAI_API_KEY)"); ws.close(1011, "No API key"); return null; }