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]

set PROXY_BASE_URL when server root path set

Ishaan Jaff900e89c0adc7
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py
index a9b49138b9c..17b23a361f6 100644
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@ -281,9 +281,12 @@ except Exception as e:
except Exception as e:
pass
+server_root_path = os.getenv("SERVER_ROOT_PATH", "")
+if server_root_path != "" and os.getenv("PROXY_BASE_URL") is None:
+ os.environ["PROXY_BASE_URL"] = server_root_path
_license_check = LicenseCheck()
premium_user: bool = _license_check.is_premium()
-ui_link = f"/ui/"
+ui_link = f"{server_root_path}/ui/"
ui_message = (
f"👉 [```LiteLLM Admin Panel on /ui```]({ui_link}). Create, Edit Keys with SSO"
)
@@ -303,14 +306,13 @@ _description = (
else f"Proxy Server to call 100+ LLMs in the OpenAI format. {custom_swagger_message}\n\n{ui_message}"
)
+
app = FastAPI(
docs_url=_docs_url,
title=_title,
description=_description,
version=version,
- root_path=os.environ.get(
- "SERVER_ROOT_PATH", ""
- ), # check if user passed root path, FastAPI defaults this value to ""
+ root_path=server_root_path, # check if user passed root path, FastAPI defaults this value to ""
)