BerriAI/litellm · error · ValueError
process_audio_file does not accept bare str tuple contents…
Error message
process_audio_file does not accept bare str tuple contents. Pass bytes, an open file handle, or a pathlib.Path.
What it means
Input validation in process_audio_file: the audio file was given as a (filename, content) tuple but the content element is a bare str. Because a str could be a path or raw text and is ambiguous/injectable over HTTP forms, the helper rejects it and asks for bytes, a file handle, or a Path.
Solutions
- In the (filename, content) tuple, make content bytes, an open file handle, or a pathlib.Path - not a bare string.
- Read the file into bytes first, e.g. (name, open(path,'rb').read()).
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/litellm_core_utils/audio_utils/utils.py:81 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/d346074dde7bb739.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/litellm_core_utils/audio_utils/utils.py:81
"an open file handle, a (filename, content) tuple, or a "
"pathlib.Path."
)
elif isinstance(audio_file, os.PathLike):
# File path or PathLike — PathLike is a Python-level type that
# HTTP form values can't fabricate.
file_path: Final = str(audio_file)
with open(file_path, "rb") as f:
file_content = f.read()
filename = file_path.split("/")[-1]
elif isinstance(audio_file, tuple):
# Tuple format: (filename, content, content_type) or (filename, content)
if len(audio_file) >= 2:
filename = audio_file[0] or "audio.wav"
content: Final = audio_file[1]
if isinstance(content, (bytes, bytearray)):
file_content = bytes(content)
elif isinstance(content, str):
raise ValueError(
"process_audio_file does not accept bare str tuple "
"contents. Pass bytes, an open file handle, or a "
"pathlib.Path."
)
elif isinstance(content, os.PathLike):
# PathLike: SDK convenience for local-file uploads.
with open(str(content), "rb") as f:
file_content = f.read()
elif hasattr(content, "read"):
# File-like object
file_content = content.read()
if hasattr(content, "seek"):
content.seek(0)
else:
raise ValueError(f"Unsupported content type in tuple: {type(content)}")
else:
raise ValueError("Tuple must have at least 2 elements: (filename, content)")
elif hasattr(audio_file, "read") and not isinstance(audio_file, (str, bytes, bytearray, tuple, os.PathLike)):View on GitHub (pinned to 77b7c6c40c)