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(responses): enforce spec object on completion bridge (#26327)

Sameer Kankute4dbea4e957fb
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"""