From 5cfd291e13e8443a9bdc5cc0deec643eef50e220 Mon Sep 17 00:00:00 2001 From: TemoSulava Date: Sun, 18 Oct 2026 14:04:50 +0400 Subject: [PATCH 1/3] 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 74f782b56e7..3403514ab57 100644 --- a/litellm/llms/aiohttp_openai/chat/transformation.py +++ b/litellm/llms/aiohttp_openai/chat/transformation.py @@ -82,4 +82,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 From ddb8930f3eaaaa00e098b1f5a4e98bffd2c73b2e Mon Sep 17 00:00:00 2001 From: TemoSulava Date: Thu, 22 Oct 2026 20:34:56 +0400 Subject: [PATCH 2/3] chore(aiohttp_openai): mark service_tier assignment rebind-ok for the type gate --- litellm/llms/aiohttp_openai/chat/transformation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/llms/aiohttp_openai/chat/transformation.py b/litellm/llms/aiohttp_openai/chat/transformation.py index 3403514ab57..0aaac824d72 100644 --- a/litellm/llms/aiohttp_openai/chat/transformation.py +++ b/litellm/llms/aiohttp_openai/chat/transformation.py @@ -83,5 +83,5 @@ class AiohttpOpenAIChatConfig(OpenAILikeChatConfig): 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") + model_response.service_tier = _json_response.get("service_tier") # rebind-ok: fills the caller's response return model_response From c20f0ec44a897407db79b280424f71f0df92e1b7 Mon Sep 17 00:00:00 2001 From: TemoSulava Date: Sun, 25 Oct 2026 12:07:15 +0400 Subject: [PATCH 3/3] fix(aiohttp_openai): set service_tier with setattr like other providers ModelResponse has no declared service_tier field, so attribute assignment added a reportAttributeAccessIssue error to the type gate. --- litellm/llms/aiohttp_openai/chat/transformation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/llms/aiohttp_openai/chat/transformation.py b/litellm/llms/aiohttp_openai/chat/transformation.py index 0aaac824d72..b82c10eb1c1 100644 --- a/litellm/llms/aiohttp_openai/chat/transformation.py +++ b/litellm/llms/aiohttp_openai/chat/transformation.py @@ -83,5 +83,5 @@ class AiohttpOpenAIChatConfig(OpenAILikeChatConfig): 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") # rebind-ok: fills the caller's response + setattr(model_response, "service_tier", _json_response.get("service_tier")) # noqa: B010 # pydantic extra, not a declared field return model_response