From 211afc9130b9049986998e33d6ef2d23306c5d79 Mon Sep 17 00:00:00 2001 From: Andrew Stout Date: Thu, 7 Aug 2025 18:06:57 -0500 Subject: [PATCH] Added initial scripts for litellm --- ct/litellm.sh | 45 +++++++++++++++++ frontend/public/json/litellm.json | 35 ++++++++++++++ install/litellm-install.sh | 80 +++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+) 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/litellm.sh b/ct/litellm.sh new file mode 100644 index 00000000..a8e9b6af --- /dev/null +++ b/ct/litellm.sh @@ -0,0 +1,45 @@ +#!/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 "Updating $APP LXC" + $STD apt-get update + pip install litellm[proxy] --upgrade + msg_ok "Updated $APP LXC" + 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 00000000..e77c7291 --- /dev/null +++ b/frontend/public/json/litellm.json @@ -0,0 +1,35 @@ +{ + "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.env", + "website": "https://www.litellm.ai/", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/litellm-light.webp", + "description": "LiteLLM description is here", + "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": [] +} diff --git a/install/litellm-install.sh b/install/litellm-install.sh new file mode 100644 index 00000000..bbaa31f3 --- /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 + +msg_info "Setup Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Setup Python3" + +msg_info "Installing ${APPLICATION}" +$STD pip install 'litellm[proxy]' +$STD pip install 'prisma' +msg_ok "Installed ${APPLICATION}" + +PG_VERSION="17" setup_postgresql + +msg_info "Setting up PostgreSQL" +DB_NAME="litellm_db" +DB_USER="${APPLICATION}" +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 "CREATE EXTENSION IF NOT EXISTS pg_trgm;" $DB_NAME +$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 "Creating Service" +mkdir -p /opt +cat </opt/${APPLICATION}.env +LITELLM_MASTER_KEY=sk-1234 +DATABASE_URL=postgresql://$DB_USER:$DB_PASS@127.0.0.1:5432/$DB_NAME +STORE_MODEL_IN_DB=true +USE_PRISMA_MIGRATE=true +EOF + +cat </etc/systemd/system/${APPLICATION}.service +[Unit] +Description=LiteLLM + +[Service] +Type=simple +EnvironmentFile=/opt/${APPLICATION}.env +ExecStart=litellm +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now "${APPLICATION}" +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"