fix(gateway): make voice transcription model configurable + router-compatible

- AI_VOICE_TRANSCRIPTION_MODEL config (default whisper-1) so the model can be a provider-qualified id (openrouter/openai/whisper-1) that actually has credentials through 9router/omniroute — bare whisper-1 maps to the openai provider which has none
- response_format json (not text): 9router proxies only json/verbose_json transcription responses; text returns 400
- parse text from the json response object
- prod env updated: model=openrouter/openai/whisper-1 (still needs OpenRouter STT balance — 402 until funded)
This commit is contained in:
asepharyana
2026-09-01 18:25:14 +07:00
parent 7ef86c81ca
commit c704fbf7a5
2 changed files with 12 additions and 3 deletions
@@ -30,12 +30,16 @@ export async function transcribeRecording(
const response = await openai.audio.transcriptions.create({
file: createReadStream(oggPath),
model: "whisper-1",
model: config.AI_VOICE_TRANSCRIPTION_MODEL,
// No `language` param → Whisper auto-detects (handles id/en mixed).
response_format: "text",
// `json` (not `text`): 9router/omniroute proxies only json/verbose_json
// transcription responses; `text` returns 400 through the router.
response_format: "json",
});
const text = typeof response === "string" ? response.trim() : null;
// With response_format "json", the SDK returns an object with `text`.
const text =
(typeof response === "string" ? response : response.text)?.trim() || null;
if (!text) {
logger.warn({ oggPath }, "Empty transcription result");
return null;
@@ -340,6 +340,11 @@ export const configSchema = z
.optional()
.transform((v) => v === "true")
.default(false),
// Whisper model routed through the LLM base URL. Through 9router/omniroute
// use a provider-qualified id that has credentials (e.g.
// openrouter/openai/whisper-1) — bare `whisper-1` maps to the `openai`
// provider which the router rejects with "No credentials for provider".
AI_VOICE_TRANSCRIPTION_MODEL: z.string().default("whisper-1"),
// ── Auto Delete ─────────────────────────────────────────────────────
AUTO_DELETE_FLAGGED_ENABLED: z