feat(stt): add server-side language fallback and extraParams for OpenAI STT provider

Add two optional fields to the OpenAI STT provider config schema:

- `language`: server-side default language (ISO 639-1) sent to Whisper when
  the client doesn't provide one. Useful for non-English deployments where
  admins want to predefine the transcription language without requiring each
  user to configure it in the browser.

- `extraParams`: arbitrary key-value pairs forwarded to the STT endpoint.
  Enables self-hosted Whisper servers (e.g. Speaches, faster-whisper-server)
  to receive provider-specific parameters like `vad_filter` (Voice Activity
  Detection) which filters silence and prevents hallucinations on empty
  audio clips. These params are ignored by the official OpenAI API.

Example librechat.yaml configuration:

```yaml
speech:
  stt:
    openai:
      url: 'http://whisper-server/v1/audio/transcriptions'
      apiKey: 'none'
      model: 'whisper-large-v3-turbo'
      language: 'pl'
      extraParams:
        vad_filter: true
```
This commit is contained in:
Mieszko Makuch 2026-03-25 11:38:57 +01:00
parent 5a373825a5
commit f158f07ee0
2 changed files with 7 additions and 1 deletions

View file

@ -206,6 +206,10 @@ class STTService {
data.language = validLanguage;
}
if (sttSchema?.extraParams) {
Object.assign(data, sttSchema.extraParams);
}
const headers = {
'Content-Type': 'multipart/form-data',
...(apiKey && { Authorization: `Bearer ${apiKey}` }),
@ -338,7 +342,7 @@ class STTService {
try {
const [provider, sttSchema] = await this.getProviderSchema(req);
const language = req.body?.language || '';
const language = req.body?.language || sttSchema?.language || '';
const text = await this.sttRequest(provider, sttSchema, { audioBuffer, audioFile, language });
res.json({ text });
} catch (error) {