diff --git a/litellm/llms/xai/chat/transformation.py b/litellm/llms/xai/chat/transformation.py index 73e3244a0e0..b0f8734fa56 100644 --- a/litellm/llms/xai/chat/transformation.py +++ b/litellm/llms/xai/chat/transformation.py @@ -14,6 +14,7 @@ from litellm.litellm_core_utils.prompt_templates.common_utils import ( strip_name_from_messages, ) from litellm.llms.base_llm.chat.transformation import BaseLLMException +from litellm.llms.openai.common_utils import OpenAIError from litellm.llms.xai.common_utils import XAIModelInfo, xai_error_status_code, xai_reported_cost_in_usd from litellm.llms.xai.cost_calculator import ( apply_server_side_tool_usage_details_to_usage, @@ -129,15 +130,12 @@ class XAIChatConfig(OpenAIGPTConfig): ) def get_error_class( - self, - error_message: str, - status_code: int, - headers: dict | httpx.Headers, # mutable-ok: mirrors the base class signature + self, error_message: str, status_code: int, headers: Mapping[str, str] | httpx.Headers ) -> BaseLLMException: - return super().get_error_class( - error_message=error_message, + return OpenAIError( status_code=xai_error_status_code(status_code, error_message), - headers=headers, + message=error_message, + headers=httpx.Headers(headers), ) def get_supported_openai_params(self, model: str) -> list: diff --git a/litellm/llms/xai/responses/transformation.py b/litellm/llms/xai/responses/transformation.py index 49dc7960c93..2383643bd20 100644 --- a/litellm/llms/xai/responses/transformation.py +++ b/litellm/llms/xai/responses/transformation.py @@ -258,15 +258,12 @@ class XAIResponsesAPIConfig(OpenAIResponsesAPIConfig): return join_api_base(api_base, "responses") def get_error_class( - self, - error_message: str, - status_code: int, - headers: dict | httpx.Headers, # mutable-ok: mirrors the base class signature + self, error_message: str, status_code: int, headers: Mapping[str, str] | httpx.Headers ) -> BaseLLMException: - return super().get_error_class( - error_message=error_message, + return BaseLLMException( status_code=xai_error_status_code(status_code, error_message), - headers=headers, + message=error_message, + headers=httpx.Headers(headers), ) def transform_response_api_response(