BerriAI/litellm · error · Exception
Unknown file type. Please pass in a file_id or file_data
Error message
Unknown file type. Please pass in a file_id or file_data
What it means
Guard in Gemini content conversion: a message part claims to be a file but carries neither file_id nor file_data (and no recognizable mime/URL payload), so there is no way to resolve the bytes and the conversion aborts.
Source
Thrown at litellm/llms/vertex_ai/gemini/transformation.py:820
if _file_field is None:
raise litellm.BadRequestError(
message="Content block has type='file' but is missing the required 'file' field",
model=model,
llm_provider="vertex_ai",
)
# TypedDict does not declare mime_type/content_type;
# read via Dict[str, Any] for caller-provided MIME fields.
file_dict = cast(dict[str, Any], _file_field)
file_id = file_dict.get("file_id")
format = (
file_dict.get("format") or file_dict.get("mime_type") or file_dict.get("content_type")
)
file_data = file_dict.get("file_data")
detail = file_dict.get("detail")
video_metadata = file_dict.get("video_metadata")
passed_file = file_id or file_data
if passed_file is None:
raise Exception("Unknown file type. Please pass in a file_id or file_data")
# Convert detail to media_resolution_enum
media_resolution_enum = _convert_detail_to_media_resolution_enum(detail)
try:
_part = _process_gemini_media(
image_url=passed_file,
format=format,
model=model,
media_resolution_enum=media_resolution_enum,
video_metadata=video_metadata,
vertex_project=vertex_project,
vertex_credentials=vertex_credentials,
)
_parts.append(_part)
except litellm.BadRequestError:
raise
except Exception as e:View on GitHub (pinned to 77b7c6c40c)
Solutions
- Pass file_id or file_data for the file content in the message.
- Check the file part structure in the messages payload.
Example fix
# include {"file_data": ...} or {"file_id": ...} in the file part. Defensive patterns
Strategy: validation
When it happens
Trigger: Triggered when a file message part has neither file_id nor file_data.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/365018e5ed84b414.
Report an issue: GitHub.