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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(utils.py): correctly re-raise azure api connection error
Krrish Dholakia59384c84a547
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex a33473b7246..d429bc6b8c1 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -1,12 +1,12 @@repos:- repo: localhooks:- - id: mypy- name: mypy- entry: python3 -m mypy --ignore-missing-imports- language: system- types: [python]- files: ^litellm/+ # - id: mypy+ # name: mypy+ # entry: python3 -m mypy --ignore-missing-imports+ # language: system+ # types: [python]+ # files: ^litellm/- id: isortname: isortentry: isortdiff --git a/litellm/exceptions.py b/litellm/exceptions.pyindex f55c0914db9..04558e437a5 100644--- a/litellm/exceptions.py+++ b/litellm/exceptions.py@@ -582,7 +582,7 @@ class APIConnectionError(openai.APIConnectionError): # type: ignoremessage,llm_provider,model,- request: httpx.Request,+ request: Optional[httpx.Request] = None,litellm_debug_info: Optional[str] = None,max_retries: Optional[int] = None,num_retries: Optional[int] = None,@@ -592,9 +592,10 @@ class APIConnectionError(openai.APIConnectionError): # type: ignoreself.model = modelself.status_code = 500self.litellm_debug_info = litellm_debug_info+ self.request = httpx.Request(method="POST", url="https://api.openai.com/v1")self.max_retries = max_retriesself.num_retries = num_retries- super().__init__(message=self.message, request=request)+ super().__init__(message=self.message, request=self.request)def __str__(self):_message = self.messagediff --git a/litellm/utils.py b/litellm/utils.pyindex 411d2509d5f..ddbd039fed0 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -7866,6 +7866,14 @@ def exception_type(model=model,litellm_debug_info=extra_information,)+ elif "Connection error" in error_str:+ exception_mapping_worked = True+ raise APIConnectionError(+ message=f"{exception_provider} APIConnectionError - {message}",+ llm_provider=custom_llm_provider,+ model=model,+ litellm_debug_info=extra_information,+ )elif hasattr(original_exception, "status_code"):exception_mapping_worked = Trueif original_exception.status_code == 400: