open-webui/open-webui · error · HTTPException
Audio conversion failed. Chat completions API requires mp3 o
Error message
Audio conversion failed. Chat completions API requires mp3 or wav format.
What it means
Raised (500) when Mistral STT runs in chat-completions mode (`audio.stt.mistral.use_chat_completions` true) and the helper `convert_audio_to_mp3(file_path)` returns a falsy value. That helper shells out through pydub/ffmpeg; it returns None when ffmpeg is missing, the binary crashes, or the input audio is unreadable. Since the chat/completions payload embeds base64 audio that Mistral only accepts as mp3 or wav, the handler aborts when conversion fails.
Source
Thrown at backend/open_webui/routers/audio.py:957
r = None
try:
model = await Config.get('audio.stt.model') or 'voxtral-mini-latest'
log.info(
f'Mistral STT - model: {model}, method: {"chat_completions" if use_chat_completions else "transcriptions"}'
)
session = await get_session()
if use_chat_completions:
audio_file_to_use = file_path
if is_audio_conversion_required(file_path):
log.debug('Converting audio to mp3 for chat completions API')
converted_path = await asyncio.to_thread(convert_audio_to_mp3, file_path)
if converted_path:
audio_file_to_use = converted_path
else:
log.error('Audio conversion failed')
raise HTTPException(
status_code=500,
detail='Audio conversion failed. Chat completions API requires mp3 or wav format.',
)
async with aiofiles.open(audio_file_to_use, 'rb') as audio_file:
raw = await audio_file.read()
audio_base64 = {
'data': base64.b64encode(raw).decode('utf-8'),
'format': mimetypes.guess_extension(mimetypes.guess_type(audio_file_to_use)[0]).lstrip('.'),
}
language = metadata.get('language', None) if metadata else None
text_instruction = (
f'Transcribe this audio exactly as spoken in {language}. Do not translate it.'
if language
else 'Transcribe this audio exactly as spoken in its original language. Do not translate it to another language.'
)
View on GitHub (pinned to 01f4282f1f)
Solutions
- Install ffmpeg on the server running Open WebUI (apt-get install -y ffmpeg) and confirm `ffmpeg -version` works as the app user.
- If ffmpeg cannot be installed, disable chat-completions mode: set audio.stt.mistral.use_chat_completions to false so the multipart /audio/transcriptions endpoint is used, which accepts other formats.
- Verify the uploaded file is playable/complete (ffprobe file.webm) and re-upload; a 0-byte file means the upload itself failed.
- Check server logs for the preceding 'Audio conversion failed' log.error line to confirm which input path failed.
Example fix
# before: engine=mistral + use_chat_completions=true, host without ffmpeg
# -> 500 'Audio conversion failed. Chat completions API requires mp3 or wav format.'
# after (option A): install decoder
# apt-get update && apt-get install -y ffmpeg
# after (option B): switch to transcriptions mode
await Config.save('audio.stt.mistral.use_chat_completions', False) Defensive patterns
Strategy: validation
Validate before calling
import shutil, mimetypes
def can_use_chat_completions_stt(path: str) -> bool:
mime = mimetypes.guess_type(path)[0]
needs_conversion = mime not in ('audio/mpeg', 'audio/wav', 'audio/x-wav')
if needs_conversion and not shutil.which('ffmpeg'):
return False # conversion will fail -> avoid 500
return True Try / catch
from fastapi import HTTPException
try:
result = await transcribe(request, path, metadata, user)
except HTTPException as e:
if 'conversion failed' in str(e.detail).lower():
if not shutil.which('ffmpeg'):
raise RuntimeError('ffmpeg missing: disable use_chat_completions or install ffmpeg') from e
raise Prevention
- Install ffmpeg in the deployment image explicitly (apt-get install -y ffmpeg) and assert shutil.which('ffmpeg') in a startup check.
- Record client audio as mp3/wav when chat-completions STT is enabled.
- Monitor for the 'Converting audio to mp3 for chat completions API' log line to catch conversion pressure early.
When it happens
Trigger: Uploading browser-recorded audio (audio/webm from MediaRecorder) or .ogg/.m4a with use_chat_completions enabled, on a host where ffmpeg is not installed or not on PATH; or uploading a zero-byte/corrupt file that pydub cannot decode.
Common situations: Docker images or slim Debian containers without the ffmpeg package; ffmpeg present but an incompatible/old version; a truncated upload (proxy cut the body) producing a non-decodable file; works locally (ffmpeg installed) but fails in CI or production container.
Related errors
- Audio conversion failed. The audio file may be corrupted or
- Failed to parse Mistral response: {str(e)}
- [ERROR: Error processing audio file]
- Mistral API key is required for Mistral STT
- Error transcribing chunk: {transcribe_exc}
AI-assisted analysis of open-webui/open-webui@01f4282f1f (2026-08-14).
Data as JSON: /api/errors/496bdeeef28da966.
Report an issue: GitHub.