danny-avila/LibreChat · warning

The audio file size exceeds the limit of 25MB

Error message

The audio file size exceeds the limit of 25MB

What it means

azureOpenAIProvider rejects any audio buffer whose byteLength exceeds 25 MiB (25*1024*1024) before constructing the multipart request. This mirrors Azure OpenAI STT's hard 25 MB upload cap; the check is local and synchronous, so no network call is wasted.

Source

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

  /**
   * Prepares the request for the Azure OpenAI STT provider.
   * @param {Object} sttSchema - The STT schema for Azure OpenAI.
   * @param {Buffer} audioBuffer - The audio data to be transcribed.
   * @param {Object} audioFile - The audio file object containing originalname, mimetype, and size.
   * @param {string} language - The language code for the transcription.
   * @returns {Array} An array containing the URL, data, and headers for the request.
   * @throws {Error} If the audio file size exceeds 25MB or the audio file format is not accepted.
   */
  azureOpenAIProvider(sttSchema, audioBuffer, audioFile, language) {
    const url = `${genAzureEndpoint({
      azureOpenAIApiInstanceName: extractEnvVariable(sttSchema?.instanceName),
      azureOpenAIApiDeploymentName: extractEnvVariable(sttSchema?.deploymentName),
    })}/audio/transcriptions?api-version=${extractEnvVariable(sttSchema?.apiVersion)}`;

    const apiKey = sttSchema.apiKey ? resolveConfigSecret(sttSchema.apiKey) || '' : '';

    if (audioBuffer.byteLength > 25 * 1024 * 1024) {
      throw new Error('The audio file size exceeds the limit of 25MB');
    }

    const acceptedFormats = ['flac', 'mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'ogg', 'wav', 'webm'];
    const [mimePrefix, rawFormat = ''] = audioFile.mimetype.split('/');
    const isAudioMime = mimePrefix === 'audio' || mimePrefix === 'video';
    const isKnownMime = audioFile.mimetype in MIME_TO_EXTENSION_MAP;
    const normalizedFormat = isKnownMime ? MIME_TO_EXTENSION_MAP[audioFile.mimetype] : null;
    if (
      !acceptedFormats.includes(normalizedFormat) &&
      !(isAudioMime && acceptedFormats.includes(rawFormat))
    ) {
      throw new Error(`The audio file format ${rawFormat} is not accepted`);
    }

    const formData = new FormData();
    formData.append('file', audioBuffer, {
      filename: audioFile.originalname,
      contentType: audioFile.mimetype,

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Compress or trim the audio below 25 MB before uploading (transcode to mp3/ogg).
  2. Downsample to a lower bitrate / mono channel.
  3. Chunk long audio on the client and send multiple requests if the provider supports it.

Example fix

// before: upload raw buffer
const audioBuffer = fs.readFileSync(recordingPath);

// after: enforce a client-side cap
const MAX = 25 * 1024 * 1024;
if (audioBuffer.byteLength > MAX) {
  throw new Error(`Audio too large: ${audioBuffer.byteLength} > ${MAX}`);
}
Defensive patterns

Strategy: validation

Validate before calling

const MAX = 25 * 1024 * 1024;
if (audioBuffer.byteLength > MAX) {
  return res.status(413).json({ error: `Audio exceeds 25MB (got ${audioBuffer.byteLength} bytes)` });
}

Prevention

When it happens

Trigger: POST /api/speech/stt using the azureOpenAI provider with a payload whose buffer is larger than 26,214,400 bytes.

Common situations: Long uncompressed WAV recordings; high-bitrate audio; no client-side size guard; user uploads a podcast-length file.

Related errors


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