BerriAI/litellm · error · ValueError
Invalid content type: {type(content)}
Error message
Invalid content type: {type(content)} What it means
Raised while converting Responses API input items to chat-completion content when a content block has an unrecognized type; the request content object shape is not one of the supported text/input_text/output_text/image variants.
Source
Thrown at litellm/responses/litellm_completion_transformation/transformation.py:1351
OpenAIChatCompletionTextObject(type="text", text=str(encrypted_content))
)
else:
# Skip text blocks with None text to avoid downstream errors
text_value = item.get("text")
if text_value is None:
continue
content_block: dict[str, object] = {
"type": LiteLLMCompletionResponsesConfig._get_chat_completion_request_content_type(
item.get("type") or "text"
),
"text": text_value,
}
if "cache_control" in item:
content_block["cache_control"] = item["cache_control"]
content_list.append(content_block)
return content_list
else:
raise ValueError(f"Invalid content type: {type(content)}")
@staticmethod
def _get_chat_completion_request_content_type(
content_type: str,
) -> ValidChatCompletionMessageContentTypesLiteral:
"""
Transform Responses API content type to valid Chat Completion content type.
Returns one of ValidChatCompletionMessageContentTypes:
- User: "text", "image_url", "input_audio", "audio_url", "document",
"guarded_text", "video_url", "file"
- Assistant: "text", "thinking", "redacted_thinking"
"""
# Responses API content has `input_` prefix, if it exists, remove it
if content_type.startswith("input_"):
stripped: Final = content_type[len("input_") :]
# Validate stripped type is valid, otherwise default to "text"
if stripped in ValidChatCompletionMessageContentTypes:View on GitHub (pinned to 77b7c6c40c)
Solutions
- Pass content as a string or a supported content-parts list.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/responses/litellm_completion_transformation/transformation.py:1351 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/407008140f73705c.
Report an issue: GitHub.