fix(tts): allow OpenAI-compatible TTS with empty apiKey by using placeholder
Update OpenAI SDK instantiation to provide a placeholder apiKey when none is supplied, enabling support for local or unauthenticated OpenAI-compatible TTS servers. Ensure Authorization header is cleared when not needed.
This commit is contained in:
parent
c1e2b5a5f0
commit
116b191c9a
1 changed files with 6 additions and 1 deletions
|
|
@ -656,7 +656,12 @@ async function runOpenAiCompatibleRequest(
|
||||||
upstreamSettings: ResolvedTtsUpstreamRuntimeSettings,
|
upstreamSettings: ResolvedTtsUpstreamRuntimeSettings,
|
||||||
): Promise<Buffer> {
|
): Promise<Buffer> {
|
||||||
const openai = new OpenAI({
|
const openai = new OpenAI({
|
||||||
apiKey: request.apiKey,
|
// The SDK constructor rejects an empty apiKey, but many OpenAI-compatible
|
||||||
|
// servers (e.g. a local Supertonic/Kokoro) need no auth. Pass a placeholder to
|
||||||
|
// satisfy the constructor; `defaultHeaders` clears the Authorization header
|
||||||
|
// (merged after the bearer auth, and allowed by validateHeaders), so the
|
||||||
|
// placeholder is never sent.
|
||||||
|
apiKey: request.apiKey || 'no-key',
|
||||||
baseURL: request.baseUrl,
|
baseURL: request.baseUrl,
|
||||||
defaultHeaders: request.apiKey ? undefined : { Authorization: null },
|
defaultHeaders: request.apiKey ? undefined : { Authorization: null },
|
||||||
maxRetries: 0,
|
maxRetries: 0,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue