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 <noreply@anthropic.com>
This commit is contained in:
parent
978f06c19a
commit
03d4fa28ca
@ -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");
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user