From 4dbea4e957fba5d6a49c71c11cc3c038081e76b4 Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Fri, 24 Apr 2026 21:59:06 +0530 Subject: [PATCH] fix(responses): enforce spec object on completion bridge (#26327) Ensure Chat Completions -> Responses bridge always emits object="response" so non-native providers return the same top-level schema as native OpenAI Responses. Made-with: Cursor --- .../litellm_completion_transformation/transformation.py | 2 +- .../test_litellm_completion_responses.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.py index 589d1f2666c..97404947006 100644 --- a/litellm/responses/litellm_completion_transformation/transformation.py +++ b/litellm/responses/litellm_completion_transformation/transformation.py @@ -1652,7 +1652,7 @@ class LiteLLMCompletionResponsesConfig: id=chat_completion_response.id, created_at=chat_completion_response.created, model=chat_completion_response.model, - object=chat_completion_response.object, + object="response", error=getattr(chat_completion_response, "error", None), incomplete_details=getattr( chat_completion_response, "incomplete_details", None diff --git a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py index f53e0391be0..5d8ff8022e5 100644 --- a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py +++ b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py @@ -369,6 +369,7 @@ class TestLiteLLMCompletionResponsesConfig: ] assert len(message_items) == 1, "Should have exactly one message item" assert message_items[0].content[0].text == "Just a regular answer." + assert responses_api_response.object == "response" def test_transform_chat_completion_response_multiple_choices_with_reasoning(self): """Test that only reasoning from first choice is included when multiple choices exist"""