From 7f9f92434d97a88aa96bd3fe6b1347927bc3811d Mon Sep 17 00:00:00 2001 From: TemoSulava Date: Sun, 18 Oct 2026 14:04:50 +0400 Subject: [PATCH] fix(aiohttp_openai): forward service_tier in transform_response --- litellm/llms/aiohttp_openai/chat/transformation.py | 2 ++ .../llms/aiohttp_openai/chat/test_transformation.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/litellm/llms/aiohttp_openai/chat/transformation.py b/litellm/llms/aiohttp_openai/chat/transformation.py index dba7a7405ab..fac415c5499 100644 --- a/litellm/llms/aiohttp_openai/chat/transformation.py +++ b/litellm/llms/aiohttp_openai/chat/transformation.py @@ -86,4 +86,6 @@ class AiohttpOpenAIChatConfig(OpenAILikeChatConfig): model_response.model = _json_response.get("model") model_response.object = _json_response.get("object") model_response.system_fingerprint = _json_response.get("system_fingerprint") + if "service_tier" in _json_response: + model_response.service_tier = _json_response.get("service_tier") return model_response diff --git a/tests/unit/llms/aiohttp_openai/chat/test_transformation.py b/tests/unit/llms/aiohttp_openai/chat/test_transformation.py index 253f9dbe746..9b61ad7a128 100644 --- a/tests/unit/llms/aiohttp_openai/chat/test_transformation.py +++ b/tests/unit/llms/aiohttp_openai/chat/test_transformation.py @@ -99,3 +99,16 @@ async def test_transform_response_rejects_choices_that_are_not_a_list_of_objects async def test_transform_response_rejects_a_choice_whose_message_is_not_an_object(): with pytest.raises(ValidationError, match="validation error for Choices"): await _transform({"choices": [{"message": "text"}]}) + + +@pytest.mark.parametrize("tier", ["flex", "priority", "default"]) +async def test_transform_response_forwards_service_tier(tier: str): + response = await _transform({"id": "chatcmpl-1", "choices": [{}], "service_tier": tier}) + + assert response.service_tier == tier + + +async def test_transform_response_service_tier_is_none_when_omitted(): + response = await _transform({"id": "chatcmpl-1", "choices": [{}]}) + + assert getattr(response, "service_tier", None) is None