danny-avila/LibreChat · error

Invalid provider

Error message

Invalid provider

What it means

ttsRequest looks up this.providerStrategies[provider]; if the provider string is not a registered strategy key (openai, azureOpenAI, elevenlabs, localai) it throws synchronously before forming the request. This prevents dispatching to an unimplemented strategy.

Source

Thrown at api/server/services/Files/Audio/TTSService.js:266

  }

  /**
   * Sends a TTS request to the specified provider.
   * @async
   * @param {string} provider - The TTS provider to use.
   * @param {Object} ttsSchema - The TTS schema for the provider.
   * @param {Object} options - The options for the TTS request.
   * @param {string} options.input - The input text.
   * @param {string} options.voice - The voice to use.
   * @param {boolean} [options.stream=true] - Whether to use streaming.
   * @param {string[]} [allowedAddresses] - Section-level SSRF exemption list of host:port pairs.
   * @returns {Promise<Object>} The axios response object.
   * @throws {Error} If the provider is invalid or the request fails.
   */
  async ttsRequest(provider, ttsSchema, { input, voice, stream = true }, allowedAddresses) {
    const strategy = this.providerStrategies[provider];
    if (!strategy) {
      throw new Error('Invalid provider');
    }

    const [url, data, headers] = strategy.call(this, ttsSchema, input, voice, stream);

    [data, headers].forEach(this.removeUndefined.bind(this));

    const options = { headers, responseType: stream ? 'stream' : 'arraybuffer' };

    applyAxiosProxyConfig(options, url);
    applySSRFSafeAgentIfDirect(options, url, allowedAddresses);

    try {
      return await axios.post(url, data, options);
    } catch (error) {
      logAxiosError({ message: `TTS request failed for provider ${provider}:`, error });
      throw error;
    }
  }

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Ensure the `speech.tts` provider key matches a supported TTSProviders constant exactly.
  2. Confirm only one provider is configured so getProvider returns the right one.
  3. Upgrade librechat-data-provider and the API service together so constant values and strategy keys agree.
Defensive patterns

Strategy: type-guard

Validate before calling

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

Type guard

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

Prevention

When it happens

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

Common situations: librechat-data-provider TTSProviders constant changed value and the service wasn't updated; config hand-edited with a wrong provider string; new 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/2e91f4bababdae65. Report an issue: GitHub.