BerriAI/litellm · error · HTTPException
'{_field}' must be provided as a multipart file upload, not
Error message
'{_field}' must be provided as a multipart file upload, not a string. What it means
Error "'{_field}' must be provided as a multipart file upload, not a string." thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/image_endpoints/endpoints.py:291
user_request_timeout,
user_temperature,
version,
)
#########################################################
# Read request body and convert UploadFiles to BytesIO
#########################################################
data: Final = await _read_request_body(request=request)
image_files: Final = await batch_to_bytesio(image)
mask_files: Final = await batch_to_bytesio(mask)
if image_files:
data["image"] = image_files
if mask_files:
data["mask"] = mask_files
for _field in ("image", "mask"):
if _field in data and isinstance(data[_field], str):
raise HTTPException(
status_code=422,
detail=f"'{_field}' must be provided as a multipart file upload, not a string.",
)
# Ensure prompt exists in data (default to None for models that don't require it)
if "prompt" not in data:
data["prompt"] = None
data["model"] = (
model
or general_settings.get("image_generation_model", None) # server default
or user_model # model name passed via cli args
or data.get("model", None) # default passed in http request
)
#########################################################
# Process request
#########################################################
View on GitHub (pinned to 77b7c6c40c)
Solutions
- Upload the field as a multipart file instead of a string value.
- Use a multipart/form-data request with the file attached under the named field.
When it happens
Trigger: Thrown at litellm/proxy/image_endpoints/endpoints.py:291 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/8a480c267d20961c.
Report an issue: GitHub.