danny-avila/LibreChat · error

Invalid provider

Error message

Invalid provider

What it means

sttRequest looks up this.providerStrategies[provider]; if the provider string is not a registered strategy key it throws synchronously before any network call. Only the providers bound in the STTService constructor are valid. This guards against an unknown/mistyped provider reaching the HTTP layer.

Source

Thrown at api/server/services/Files/Audio/STTService.js:294

  }

  /**
   * Sends an STT request to the specified provider.
   * @async
   * @param {string} provider - The STT provider to use.
   * @param {Object} sttSchema - The STT schema for the provider.
   * @param {Object} requestData - The data required for the STT request.
   * @param {Buffer} requestData.audioBuffer - The audio data to be transcribed.
   * @param {Object} requestData.audioFile - The audio file object containing originalname, mimetype, and size.
   * @param {string} requestData.language - The language code for the transcription.
   * @param {string[]} [allowedAddresses] - Section-level SSRF exemption list of host:port pairs.
   * @returns {Promise<string>} A promise that resolves to the transcribed text.
   * @throws {Error} If the provider is invalid, the response status is not 200, or the response data is missing.
   */
  async sttRequest(provider, sttSchema, { audioBuffer, audioFile, language }, allowedAddresses) {
    const strategy = this.providerStrategies[provider];
    if (!strategy) {
      throw new Error('Invalid provider');
    }

    const fileExtension = getFileExtensionFromMime(audioFile.mimetype);

    const audioReadStream = Readable.from(audioBuffer);
    audioReadStream.path = `audio.${fileExtension}`;

    const [url, data, headers] = strategy.call(
      this,
      sttSchema,
      audioReadStream,
      audioFile,
      language,
    );

    const options = { headers };

    applyAxiosProxyConfig(options, url);

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Ensure the `speech.stt` provider key matches a supported STTProviders constant exactly.
  2. Confirm only one provider is configured (getProviderSchema returns the sole entry).
  3. Upgrade librechat-data-provider and the API service together so the constant values and strategy keys agree.
Defensive patterns

Strategy: type-guard

Validate before calling

const { STTProviders } = require('librechat-data-provider');
if (!Object.values(STTProviders).includes(provider)) {
  throw new Error(`Unknown STT provider: ${provider}`);
}

Type guard

/** @param {string} p */
function isValidSttProvider(p) {
  const { STTProviders } = require('librechat-data-provider');
  return Object.values(STTProviders).includes(p);
}

Prevention

When it happens

Trigger: The provider returned by getProviderSchema (or passed directly) does not match a key in providerStrategies — e.g. casing mismatch, a constant value that drifted, or a provider name configured that has no strategy implementation.

Common situations: librechat-data-provider STTProviders constant value changed and the service wasn't updated; config hand-edited with a wrong provider string; future provider referenced before its strategy was implemented.

Related errors


AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12). Data as JSON: /api/errors/d3cad5ba42dbe2ca. Report an issue: GitHub.