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

Error "process_audio_file does not accept bare str tuple contents. Pass bytes, an open file handle, or a pathlib.Path." thrown in BerriAI/litellm.

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 6c2dcb801b)

Solutions

  1. Pass bytes, an open file handle, or a pathlib.Path inside the tuple instead of a string.

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@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/d346074dde7bb739. Report an issue: GitHub.