Created
February 20, 2026 21:28
-
-
Save praveenc/4206a15bd2623c90173b9a01ad3deabc to your computer and use it in GitHub Desktop.
Start litellm proxy (local)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # ── Resolve script directory ── | |
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| # ── Activate virtual environment ── | |
| VENV_DIR="${SCRIPT_DIR}/.venv" | |
| if [[ ! -f "${VENV_DIR}/bin/activate" ]]; then | |
| echo "Error: virtual environment not found at ${VENV_DIR}" >&2 | |
| echo " Create one with: python -m venv ${VENV_DIR} && source ${VENV_DIR}/bin/activate && pip install litellm" >&2 | |
| exit 3 | |
| fi | |
| # shellcheck disable=SC1091 | |
| source "${VENV_DIR}/bin/activate" | |
| # ── Configuration ── | |
| CONFIG_FILE="${LITELLM_CONFIG:-${SCRIPT_DIR}/config.yaml}" | |
| LITELLM_PORT="${LITELLM_PORT:-4000}" | |
| export UI_USERNAME="${UI_USERNAME:-username}" | |
| export UI_PASSWORD="${UI_PASSWORD:-defpassword}" | |
| # Only set DATABASE_URL if you need spend tracking / virtual keys (requires prisma) | |
| # export DATABASE_URL="${DATABASE_URL:-sqlite:///tmp/litellm.db}" | |
| # ── Preflight checks ── | |
| if ! command -v litellm &>/dev/null; then | |
| echo "Error: litellm is not installed or not on PATH." >&2 | |
| echo " Install with: pip install litellm" >&2 | |
| exit 1 | |
| fi | |
| if [[ ! -f "$CONFIG_FILE" ]]; then | |
| echo "Error: config file not found: $CONFIG_FILE" >&2 | |
| echo " Set LITELLM_CONFIG to override the path." >&2 | |
| exit 2 | |
| fi | |
| # ── Graceful shutdown ── | |
| cleanup() { | |
| echo "" | |
| echo "Shutting down LiteLLM (PID $$)..." | |
| # litellm is exec'd into this PID, so the signal propagates automatically | |
| exit 0 | |
| } | |
| trap cleanup SIGINT SIGTERM | |
| echo "Starting LiteLLM..." | |
| echo " Config: $CONFIG_FILE" | |
| echo " Port: $LITELLM_PORT" | |
| echo " DB: ${DATABASE_URL:-<none>}" | |
| echo " UI user: $UI_USERNAME" | |
| echo "" | |
| exec litellm --config "$CONFIG_FILE" --port "$LITELLM_PORT" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment