diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index d9c85623a..7cc196ffe 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -91,6 +91,7 @@ from litellm.proxy.utils import ( reset_budget, hash_token, html_form, + missing_keys_html_form, _read_request_body, _is_valid_team_configs, _is_user_proxy_admin, @@ -5140,6 +5141,13 @@ async def moderations( #### DEV UTILS #### +# @router.get( +# "/utils/available_routes", +# tags=["llm utils"], +# dependencies=[Depends(user_api_key_auth)], +# ) +# async def get_available_routes(user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth)): + @router.post( "/utils/token_counter", @@ -9582,7 +9590,8 @@ async def google_login(request: Request): PROXY_BASE_URL should be the your deployed proxy endpoint, e.g. PROXY_BASE_URL="https://litellm-production-7002.up.railway.app/" Example: """ - global premium_user + global premium_user, prisma_client, master_key + microsoft_client_id = os.getenv("MICROSOFT_CLIENT_ID", None) google_client_id = os.getenv("GOOGLE_CLIENT_ID", None) generic_client_id = os.getenv("GENERIC_CLIENT_ID", None) @@ -9601,6 +9610,12 @@ async def google_login(request: Request): code=status.HTTP_403_FORBIDDEN, ) + ####### Detect DB + MASTER KEY in .env ####### + if prisma_client is None and master_key is None: + from fastapi.responses import HTMLResponse + + return HTMLResponse(content=missing_keys_html_form, status_code=200) + # get url from request redirect_url = os.getenv("PROXY_BASE_URL", str(request.base_url)) ui_username = os.getenv("UI_USERNAME") diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index b22134dab..9ca8404bf 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -2713,3 +2713,66 @@ html_form = """ """ + + +missing_keys_html_form = """ + + + + + + + Environment Setup Instructions + + +
+

Environment Setup Instructions

+

Please add the following configurations to your environment variables:

+
+LITELLM_MASTER_KEY="sk-1234" # make this unique. must start with `sk-`.
+DATABASE_URL="postgres://..." # Need a postgres database? (Check out Supabase, Neon, etc)
+
+## OPTIONAL ##
+PORT=4000 # DO THIS FOR RENDER/RAILWAY
+STORE_MODEL_IN_DB="True" # Allow storing models in db
+            
+
+ + + """