Skip to content

Commit 600b19c

Browse files
committed
fix: handle bare input_image/input_text/input_file items in Responses-to-completion transformation
1 parent 7d1c83a commit 600b19c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

litellm/responses/litellm_completion_transformation/transformation.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,18 @@ def _transform_responses_api_input_item_to_chat_completion_message(
976976
function_call=input_item
977977
)
978978
else:
979+
item_type = input_item.get("type")
980+
# Handle bare content items (input_text, input_image, input_file)
981+
# that appear at the top level without a message wrapper.
982+
if item_type in ("input_text", "input_image", "input_file"):
983+
return [
984+
GenericChatCompletionMessage(
985+
role="user",
986+
content=LiteLLMCompletionResponsesConfig._transform_responses_api_content_to_chat_completion_content(
987+
[input_item]
988+
),
989+
)
990+
]
979991
content = input_item.get("content")
980992
# Handle None content: Responses API allows None content, but GenericChatCompletionMessage requires content
981993
# Since guardrails skip None content anyway, we return empty list to exclude it from structured messages

0 commit comments

Comments
 (0)