Skip to content

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]

fix: export PermissionDeniedError from litellm.__init__

Cas Steigstra2ef0d9e80a7c
diff --git a/litellm/__init__.py b/litellm/__init__.py
index dacb928e8a7..538ee727612 100644
--- a/litellm/__init__.py
+++ b/litellm/__init__.py
@@ -1155,6 +1155,7 @@ from .exceptions import (
BadRequestError,
ImageFetchError,
NotFoundError,
+ PermissionDeniedError,
RateLimitError,
ServiceUnavailableError,
BadGatewayError,
diff --git a/tests/test_litellm/test_exception_exports.py b/tests/test_litellm/test_exception_exports.py
new file mode 100644
index 00000000000..cde26295bad
--- /dev/null
+++ b/tests/test_litellm/test_exception_exports.py
@@ -0,0 +1,31 @@
+"""
+Test that all standard HTTP error exceptions are exported from litellm.__init__.
+"""
+
+import litellm
+
+
+def test_permission_denied_error_is_exported():
+ """PermissionDeniedError (403) should be accessible as litellm.PermissionDeniedError."""
+ assert hasattr(litellm, "PermissionDeniedError")
+ assert litellm.PermissionDeniedError is not None
+
+
+def test_all_http_error_exceptions_exported():
+ """All standard HTTP error exceptions should be accessible at module level."""
+ expected_exceptions = [
+ "BadRequestError", # 400
+ "AuthenticationError", # 401
+ "PermissionDeniedError", # 403
+ "NotFoundError", # 404
+ "Timeout", # 408
+ "UnprocessableEntityError", # 422
+ "RateLimitError", # 429
+ "InternalServerError", # 500
+ "BadGatewayError", # 502
+ "ServiceUnavailableError", # 503
+ ]
+ for exc_name in expected_exceptions:
+ assert hasattr(litellm, exc_name), (
+ f"litellm.{exc_name} is not exported from litellm.__init__"
+ )