Skip to content

Conversation

@Chesars
Copy link
Contributor

@Chesars Chesars commented Dec 5, 2025

Relevant issues

Fixes #17507

Pre-Submission checklist

  • I have Added testing in the tests/litellm/ directory
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Description

When using litellm.completion() with models that only support the Responses API (gpt-5.1-codex, o1-pro, o3-pro, etc.), LiteLLM automatically transforms the request from Chat Completions format to Responses API format.

The Responses API expects tool results in this format:

# Responses API format 
{
    "type": "function_call_output",
    "call_id": "call_abc123",
    "output": [
        {"type": "output_text", "text": "Screenshot captured"},
        {"type": "input_image", "image_url": "data:image/png;base64,..."}
    ]
}

But we were sending Chat Completions format:

# Chat Completions format (what we were sending)
{
    "type": "function_call_output",
    "call_id": "call_abc123", 
    "output": [
        {"type": "text", "text": "Screenshot captured"},
        {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}}
    ]
}

Fix

Updated litellm/completion_extras/litellm_responses_transformation/transformation.py to transform tool output content when it's a list:

  • {"type": "text"}{"type": "output_text"}
  • {"type": "image_url", "image_url": {"url": "..."}}{"type": "input_image", "image_url": "..."}

Tests

  • test_convert_tool_output_to_responses_format
  • test_convert_tool_output_string_content_unchanged

When using models that route through the Responses API (gpt-5-codex, o1-pro, etc.),
tool message content with multimodal data was passed directly without transforming
the type fields, causing 400 Bad Request errors.

This fix transforms:
- {"type": "text", ...} -> {"type": "output_text", ...}
- {"type": "image_url", ...} -> {"type": "input_image", ...}

Fixes BerriAI#17507
@vercel
Copy link

vercel bot commented Dec 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Dec 5, 2025 6:44pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Chat-to-Responses API Bridge Doesn't Transform Tool Output Content Types

1 participant