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(proxy_server.py): fix loading ui on custom root path (#11912)
Krish Dholakia0e6f1c089d12
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex a980de69d55..47e090016d9 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -6957,49 +6957,6 @@"supports_web_search": true,"supports_pdf_input": true},- "gemini/gemini-2.5-flash-lite-preview-06-17": {- "max_tokens": 65535,- "max_input_tokens": 1048576,- "max_output_tokens": 65535,- "max_images_per_prompt": 3000,- "max_videos_per_prompt": 10,- "max_video_length": 1,- "max_audio_length_hours": 8.4,- "max_audio_per_prompt": 1,- "max_pdf_size_mb": 30,- "input_cost_per_audio_token": 5e-07,- "input_cost_per_token": 1e-07,- "output_cost_per_token": 4e-07,- "output_cost_per_reasoning_token": 4e-07,- "litellm_provider": "gemini",- "mode": "chat",- "supports_reasoning": true,- "supports_system_messages": true,- "supports_function_calling": true,- "supports_vision": true,- "supports_response_schema": true,- "supports_audio_output": false,- "supports_tool_choice": true,- "supported_endpoints": [- "/v1/chat/completions",- "/v1/completions",- "/v1/batch"- ],- "supported_modalities": [- "text",- "image",- "audio",- "video"- ],- "supported_output_modalities": [- "text"- ],- "source": "https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-lite",- "supports_parallel_function_calling": true,- "supports_web_search": true,- "supports_url_context": true,- "supports_pdf_input": true- },"gemini/gemini-2.5-flash-lite-preview-06-17": {"max_tokens": 65535,"max_input_tokens": 1048576,@@ -7042,7 +6999,8 @@"source": "https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-lite","supports_parallel_function_calling": true,"supports_web_search": true,- "supports_url_context": true+ "supports_url_context": true,+ "supports_pdf_input": true},"gemini-2.5-flash-preview-05-20": {"max_tokens": 65535,diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.pyindex 55d3d895741..ef765d89b47 100644--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@ -752,21 +752,6 @@ try:current_dir = os.path.dirname(os.path.abspath(__file__))ui_path = os.path.join(current_dir, "_experimental", "out")litellm_asset_prefix = "/litellm-asset-prefix"- # # Mount the _next directory at the root level- app.mount(- "/_next",- StaticFiles(directory=os.path.join(ui_path, "_next")),- name="next_static",- )- app.mount(- f"{litellm_asset_prefix}/_next",- StaticFiles(directory=os.path.join(ui_path, "_next")),- name="next_static",- )- # print(f"mounted _next at {server_root_path}/ui/_next")-- app.mount("/ui", StaticFiles(directory=ui_path, html=True), name="ui")-# Iterate through files in the UI directoryfor root, dirs, files in os.walk(ui_path):for filename in files:@@ -792,19 +777,37 @@ try:# Replace the asset prefix with the server root pathmodified_content = content.replace(- f"{litellm_asset_prefix}", server_root_path+ f"{litellm_asset_prefix}",+ f"{server_root_path}",)+# Replace the /.well-known/litellm-ui-config with the server root pathmodified_content = modified_content.replace("/litellm/.well-known/litellm-ui-config",f"{server_root_path}/.well-known/litellm-ui-config",)+with open(file_path, "w", encoding="utf-8") as f:f.write(modified_content)except UnicodeDecodeError:# Skip binary files that can't be decodedcontinue+ # # Mount the _next directory at the root level+ app.mount(+ "/_next",+ StaticFiles(directory=os.path.join(ui_path, "_next")),+ name="next_static",+ )+ app.mount(+ f"{litellm_asset_prefix}/_next",+ StaticFiles(directory=os.path.join(ui_path, "_next")),+ name="next_static",+ )+ # print(f"mounted _next at {server_root_path}/ui/_next")++ app.mount("/ui", StaticFiles(directory=ui_path, html=True), name="ui")+# Handle HTML file restructuringfor filename in os.listdir(ui_path):if filename.endswith(".html") and filename != "index.html":