danny-avila/LibreChat · warning

The audio file format ${rawFormat} is not accepted

Error message

The audio file format ${rawFormat} is not accepted

What it means

azureOpenAIProvider accepts only flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. It first normalizes the upload's MIME through MIME_TO_EXTENSION_MAP; if not mapped, it falls back to the subtype after the `/`. If neither result is in acceptedFormats, it throws with the offending subtype.

Source

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

      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,
    });

    const validLanguage = getValidatedLanguageCode(language);
    if (validLanguage) {
      formData.append('language', validLanguage);
    }

    const headers = {
      ...(apiKey && { 'api-key': apiKey }),
    };

    [headers].forEach(this.removeUndefined);

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Transcode the file to an accepted format (mp3, wav, ogg, or webm) before upload.
  2. Ensure the upload's Content-Type/mimetype is correct for the actual bytes.
  3. Only if a mapped format is genuinely supported by your deployment, extend MIME_TO_EXTENSION_MAP to normalize it into an accepted extension.

Example fix

// before: send audio/aac directly
// after: transcode to mp3 before upload (ffmpeg)
// ffmpeg -i input.aac -codec:a libmp3lame output.mp3
Defensive patterns

Strategy: validation

Validate before calling

const ACCEPTED = ['flac','mp3','mp4','mpeg','mpga','m4a','ogg','wav','webm'];
const [, raw = ''] = audioFile.mimetype.split('/');
if (!ACCEPTED.includes(rawFormat)) {
  return res.status(415).json({ error: `Unsupported audio format: ${rawFormat}` });
}

Prevention

When it happens

Trigger: Upload audio whose normalized extension and raw subtype are both outside the allowlist — e.g. audio/aac, audio/x-aiff, audio/ac3, video/quicktime.

Common situations: Browser reports an uncommon MIME; recorder produces AAC/AIFF; multer/file-type detection mislabels the file; user uploads a container the provider doesn't support.

Related errors


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