Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix: map Chat Completion file type to Responses API input_file

Ethan T.0bdfd95ad879
diff --git a/litellm/completion_extras/litellm_responses_transformation/transformation.py b/litellm/completion_extras/litellm_responses_transformation/transformation.py
index 4b31bcfc285..ab69e9ca13f 100644
--- a/litellm/completion_extras/litellm_responses_transformation/transformation.py
+++ b/litellm/completion_extras/litellm_responses_transformation/transformation.py
@@ -693,6 +693,20 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge):
verbose_logger.debug(
f"Chat provider: image -> {converted}"
)
+ elif item_type == "file":
+ # Map Chat Completion file to Responses API input_file
+ # {"type": "file", "file": {"file_data": "...", "filename": "..."}}
+ # -> {"type": "input_file", "file_data": "...", "filename": "..."}
+ file_data = item.get("file", {})
+ converted = {"type": "input_file"}
+ if isinstance(file_data, dict):
+ for key in ["file_id", "file_data", "filename"]:
+ if key in file_data:
+ converted[key] = file_data[key]
+ result.append(converted)
+ verbose_logger.debug(
+ f"Chat provider: file -> {converted}"
+ )
elif item_type in [
"input_text",
"input_image",