fix(xai): type spending-limit error-class overrides without bare dict

This commit is contained in:
hx 2026-10-15 20:08:42 +08:00
parent 91ea07c9c7
commit 5e211a4a86
2 changed files with 9 additions and 14 deletions

View file

@ -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:

View file

@ -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(