import os def show_missing_vars_in_env(): from fastapi.responses import HTMLResponse from litellm.proxy.proxy_server import master_key, prisma_client if prisma_client is None and master_key is None: return HTMLResponse( content=missing_keys_form( missing_key_names="DATABASE_URL, LITELLM_MASTER_KEY" ), status_code=200, ) if prisma_client is None: return HTMLResponse( content=missing_keys_form(missing_key_names="DATABASE_URL"), status_code=200 ) if master_key is None: return HTMLResponse( content=missing_keys_form(missing_key_names="LITELLM_MASTER_KEY"), status_code=200, ) return None # LiteLLM Admin UI - Non SSO Login url_to_redirect_to = os.getenv("PROXY_BASE_URL", "") url_to_redirect_to += "/login" html_form = f""" LiteLLM Login

LiteLLM Login

By default Username is "admin" and Password is your set LiteLLM Proxy `MASTER_KEY`

If you need to set UI credentials / SSO docs here: https://docs.litellm.ai/docs/proxy/ui


""" def missing_keys_form(missing_key_names: str): missing_keys_html_form = """ Environment Setup Instructions

Environment Setup Instructions

Please add the following variables to your environment variables:

    LITELLM_MASTER_KEY="sk-1234" # Your master key for the proxy server. Can use this to send /chat/completion requests etc
    LITELLM_SALT_KEY="sk-XXXXXXXX" # Can NOT CHANGE THIS ONCE SET - It is used to encrypt/decrypt credentials stored in DB. If value of 'LITELLM_SALT_KEY' changes your models cannot be retrieved from DB
    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
                

Missing Environment Variables

{missing_keys}

Need Help? Support

Discord: https://discord.com/invite/wuPM9dRgDw

Docs: https://docs.litellm.ai/docs/

""" return missing_keys_html_form.format(missing_keys=missing_key_names) def admin_ui_disabled(): from fastapi.responses import HTMLResponse ui_disabled_html = """ Admin UI Disabled

Admin UI is Disabled

The Admin UI has been disabled by the administrator. To re-enable it, please update the following environment variable:

    DISABLE_ADMIN_UI="False" # Set this to "False" to enable the Admin UI.
                

After making this change, restart the application for it to take effect.

Need Help? Support

Discord: https://discord.com/invite/wuPM9dRgDw

Docs: https://docs.litellm.ai/docs/

""" return HTMLResponse( content=ui_disabled_html, status_code=200, )