From f799c907126a51a147fe80ee2ac100af14f90231 Mon Sep 17 00:00:00 2001 From: "push-app-to-main[bot]" <203845782+push-app-to-main[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 20:04:40 +0200 Subject: [PATCH] 'Add new script' (#7052) Co-authored-by: push-app-to-main[bot] <203845782+push-app-to-main[bot]@users.noreply.github.com> --- ct/headers/litellm | 6 +++ ct/litellm.sh | 60 +++++++++++++++++++++++ frontend/public/json/litellm.json | 40 ++++++++++++++++ install/litellm-install.sh | 80 +++++++++++++++++++++++++++++++ 4 files changed, 186 insertions(+) create mode 100644 ct/headers/litellm create mode 100644 ct/litellm.sh create mode 100644 frontend/public/json/litellm.json create mode 100644 install/litellm-install.sh diff --git a/ct/headers/litellm b/ct/headers/litellm new file mode 100644 index 000000000..1360a8ff9 --- /dev/null +++ b/ct/headers/litellm @@ -0,0 +1,6 @@ + __ _ __ __ __ __ ___ + / / (_) /____ / / / / / |/ / + / / / / __/ _ \/ / / / / /|_/ / + / /___/ / /_/ __/ /___/ /___/ / / / +/_____/_/\__/\___/_____/_____/_/ /_/ + diff --git a/ct/litellm.sh b/ct/litellm.sh new file mode 100644 index 000000000..669eb6471 --- /dev/null +++ b/ct/litellm.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: stout01 +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/BerriAI/litellm + +APP="LiteLLM" +var_tags="${var_tags:-ai;interface}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-4}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /etc/systemd/system/litellm.service ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + msg_info "Stopping ${APP}" + systemctl stop litellm + msg_ok "Stopped ${APP}" + + VENV_PATH="/opt/litellm/.venv" + PYTHON_VERSION="3.13" setup_uv + + msg_info "Updating $APP" + $STD "$VENV_PATH/bin/python" -m pip install --upgrade litellm[proxy] prisma + + msg_info "Updating DB Schema" + $STD uv --directory=/opt/litellm run litellm --config /opt/litellm/litellm.yaml --use_prisma_db_push --skip_server_startup + msg_ok "DB Schema Updated" + + msg_info "Starting ${APP}" + systemctl start litellm + msg_ok "Started ${APP}" + msg_ok "Updated Successfully" + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4000${CL}" diff --git a/frontend/public/json/litellm.json b/frontend/public/json/litellm.json new file mode 100644 index 000000000..b2e7b7d79 --- /dev/null +++ b/frontend/public/json/litellm.json @@ -0,0 +1,40 @@ +{ + "name": "LiteLLM", + "slug": "litellm", + "categories": [ + 20 + ], + "date_created": "2025-08-07", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 4000, + "documentation": "https://docs.litellm.ai/", + "config_path": "/opt/litellm/litellm.yaml", + "website": "https://www.litellm.ai/", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/litellm-light.webp", + "description": "LLM proxy to call 100+ LLMs in a unified interface & track spend, set budgets per virtual key/user", + "install_methods": [ + { + "type": "default", + "script": "ct/litellm.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 4, + "os": "Debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": "admin", + "password": "sk-1234" + }, + "notes": [ + { + "text": "Update master key in the config file", + "type": "info" + } + ] +} diff --git a/install/litellm-install.sh b/install/litellm-install.sh new file mode 100644 index 000000000..b79341f99 --- /dev/null +++ b/install/litellm-install.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: stout01 +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/BerriAI/litellm + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +PG_VERSION="17" setup_postgresql +PYTHON_VERSION="3.13" setup_uv + +msg_info "Setting up PostgreSQL" +DB_NAME="litellm_db" +DB_USER="litellm" +DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)" +$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';" +{ + echo "${APPLICATION} Credentials" + echo "Database Name: $DB_NAME" + echo "Database User: $DB_USER" + echo "Database Password: $DB_PASS" +} >>~/litellm.creds +msg_ok "Set up PostgreSQL" + +msg_info "Setting up Virtual Environment" +mkdir -p /opt/litellm +cd /opt/litellm +$STD uv venv /opt/litellm/.venv +$STD /opt/litellm/.venv/bin/python -m ensurepip --upgrade +$STD /opt/litellm/.venv/bin/python -m pip install --upgrade pip +$STD /opt/litellm/.venv/bin/python -m pip install litellm[proxy] prisma +msg_ok "Installed LiteLLM" + +msg_info "Configuring LiteLLM" +mkdir -p /opt +cat </opt/litellm/litellm.yaml +general_settings: + master_key: sk-1234 + database_url: postgresql://$DB_USER:$DB_PASS@127.0.0.1:5432/$DB_NAME + store_model_in_db: true +EOF + +uv --directory=/opt/litellm run litellm --config /opt/litellm/litellm.yaml --use_prisma_db_push --skip_server_startup +msg_ok "Configured LiteLLM" + +msg_info "Creating Service" +cat </etc/systemd/system/litellm.service +[Unit] +Description=LiteLLM + +[Service] +Type=simple +ExecStart=uv --directory=/opt/litellm run litellm --config /opt/litellm/litellm.yaml +Restart=always + +[Install] +WantedBy=multi-user.target +EOF + +systemctl enable -q --now litellm +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"