BerriAI/litellm · error · ValueError
calculate_request_duration does not accept bare str inputs.
Error message
calculate_request_duration does not accept bare str inputs. Pass bytes, an open file handle, a (filename, content) tuple, or a pathlib.Path.
What it means
Error "calculate_request_duration does not accept bare str inputs. Pass bytes, an open file handle, a (filename, content) tuple, or a pathlib.Path." thrown in BerriAI/litellm.
Source
Thrown at litellm/litellm_core_utils/audio_utils/utils.py:279
"""
try:
import soundfile as sf
except ImportError:
# soundfile not available, cannot extract duration
return None
try:
import io
# Handle different file input types
file_content: bytes | None = None
if isinstance(file, (bytes, bytearray)):
# Raw bytes
file_content = bytes(file)
elif isinstance(file, str):
# Bare strings are rejected — see extract_file_data.
raise ValueError(
"calculate_request_duration does not accept bare str inputs. "
"Pass bytes, an open file handle, a (filename, content) "
"tuple, or a pathlib.Path."
)
elif isinstance(file, os.PathLike):
# File path (PathLike): SDK convenience.
with open(str(file), "rb") as f:
file_content = f.read()
elif isinstance(file, tuple):
# Tuple format: (filename, content, optional content_type)
if len(file) >= 2:
content: Final = file[1]
if isinstance(content, bytes):
file_content = content
elif hasattr(content, "read") and not isinstance(content, (str, os.PathLike)):
# File-like object in tuple
current_pos: Final = getattr(content, "tell", lambda: None)()
# Seek to start to ensure we read the entire contentView on GitHub (pinned to 6c2dcb801b)
Solutions
- Pass bytes, an open file handle, a (filename, content) tuple, or a pathlib.Path instead of a bare string.
When it happens
Trigger: Thrown at litellm/litellm_core_utils/audio_utils/utils.py:279 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/cb68064d6cf0b374.
Report an issue: GitHub.