From 38880fd5ce266ee2abd8f38a635149ba82d5d9d5 Mon Sep 17 00:00:00 2001 From: nate-berri Date: Sat, 10 Oct 2026 12:06:04 -0700 Subject: [PATCH] refactor(types): move CommonProxyErrors into litellm/types/proxy (#45745) Part of LIT-9423 --- litellm/integrations/gcs_bucket/gcs_bucket.py | 4 ++-- litellm/proxy/_types.py | 15 +++------------ litellm/secret_managers/google_secret_manager.py | 2 +- litellm/types/proxy/common_proxy_errors.py | 15 +++++++++++++++ 4 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 litellm/types/proxy/common_proxy_errors.py diff --git a/litellm/integrations/gcs_bucket/gcs_bucket.py b/litellm/integrations/gcs_bucket/gcs_bucket.py index 092357ae92b..24a5e940e08 100644 --- a/litellm/integrations/gcs_bucket/gcs_bucket.py +++ b/litellm/integrations/gcs_bucket/gcs_bucket.py @@ -26,8 +26,8 @@ else: class GCSBucketLogger(GCSBucketBase, AdditionalLoggingUtils): def __init__(self, bucket_name: str | None = None) -> None: - from litellm.proxy._types import CommonProxyErrors from litellm.proxy.proxy_server import premium_user + from litellm.types.proxy.common_proxy_errors import CommonProxyErrors self.batch_size = int(os.getenv("GCS_BATCH_SIZE", GCS_DEFAULT_BATCH_SIZE)) self.flush_interval = int(os.getenv("GCS_FLUSH_INTERVAL", GCS_DEFAULT_FLUSH_INTERVAL_SECONDS)) @@ -52,8 +52,8 @@ class GCSBucketLogger(GCSBucketBase, AdditionalLoggingUtils): #### ASYNC #### async def async_log_success_event(self, kwargs, response_obj, start_time, end_time): - from litellm.proxy._types import CommonProxyErrors from litellm.proxy.proxy_server import premium_user + from litellm.types.proxy.common_proxy_errors import CommonProxyErrors if premium_user is not True: raise ValueError( diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py index 2afab2e117e..5882323bc48 100644 --- a/litellm/proxy/_types.py +++ b/litellm/proxy/_types.py @@ -4345,18 +4345,9 @@ class ModelAccessDeniedProxyException(ProxyException): return self.internal_message.replace("\r", "").replace("\n", "") -class CommonProxyErrors(str, enum.Enum): - db_not_connected_error = ( - "DB not connected. This endpoint needs a database; set DATABASE_URL to a " - "PostgreSQL connection string (postgresql://...) to enable it. " - "See https://docs.litellm.ai/docs/proxy/virtual_keys" - ) - no_llm_router = "No models configured on proxy" - not_allowed_access = "Admin-only endpoint. Not allowed to access this." - not_premium_user = "You must be a LiteLLM Enterprise user to use this feature. If you have a license please set `LITELLM_LICENSE` in your env. Get a 7 day trial key here: https://www.litellm.ai/enterprise#trial. \nPricing: https://www.litellm.ai/#pricing" - max_parallel_request_limit_reached = "Crossed TPM / RPM / Max Parallel Request Limit" - missing_enterprise_package = "Missing litellm-enterprise package. Please install it to use this feature. Run `pip install litellm-enterprise`" - missing_enterprise_package_docker = "This uses the enterprise folder - only available on the Docker image." +from litellm.types.proxy.common_proxy_errors import ( # noqa: E402 # public re-export + CommonProxyErrors as CommonProxyErrors, # noqa: PLC0414 # public re-export +) class SpendCalculateRequest(LiteLLMPydanticObjectBase): diff --git a/litellm/secret_managers/google_secret_manager.py b/litellm/secret_managers/google_secret_manager.py index 2a5152179bb..6d6543cee4b 100644 --- a/litellm/secret_managers/google_secret_manager.py +++ b/litellm/secret_managers/google_secret_manager.py @@ -8,7 +8,7 @@ from litellm.caching.caching import InMemoryCache from litellm.constants import SECRET_MANAGER_REFRESH_INTERVAL from litellm.integrations.gcs_bucket.gcs_bucket_base import GCSBucketBase from litellm.llms.custom_httpx.http_handler import get_httpx_client -from litellm.proxy._types import CommonProxyErrors +from litellm.types.proxy.common_proxy_errors import CommonProxyErrors from litellm.types.secret_managers.main import KeyManagementSystem diff --git a/litellm/types/proxy/common_proxy_errors.py b/litellm/types/proxy/common_proxy_errors.py new file mode 100644 index 00000000000..51426220c82 --- /dev/null +++ b/litellm/types/proxy/common_proxy_errors.py @@ -0,0 +1,15 @@ +import enum + + +class CommonProxyErrors(str, enum.Enum): + db_not_connected_error = ( + "DB not connected. This endpoint needs a database; set DATABASE_URL to a " + "PostgreSQL connection string (postgresql://...) to enable it. " + "See https://docs.litellm.ai/docs/proxy/virtual_keys" + ) + no_llm_router = "No models configured on proxy" + not_allowed_access = "Admin-only endpoint. Not allowed to access this." + not_premium_user = "You must be a LiteLLM Enterprise user to use this feature. If you have a license please set `LITELLM_LICENSE` in your env. Get a 7 day trial key here: https://www.litellm.ai/enterprise#trial. \nPricing: https://www.litellm.ai/#pricing" + max_parallel_request_limit_reached = "Crossed TPM / RPM / Max Parallel Request Limit" + missing_enterprise_package = "Missing litellm-enterprise package. Please install it to use this feature. Run `pip install litellm-enterprise`" + missing_enterprise_package_docker = "This uses the enterprise folder - only available on the Docker image."