AI with Open WebUI + LiteLLM: Self-Hosted AI Solution

A comprehensive guide to setting up your own AI server with Open WebUI and LiteLLM, allowing you to access multiple AI models from a single self-hosted interface.

AI with Open WebUI + LiteLLM: Self-Hosted AI Solution

Run OpenWebUI on your own VPS with Hostinger and create a powerful self-hosted AI environment. This setup allows you to use multiple AI models simultaneously, creating a one-to-many scenario where you can compare responses across different models. For example, you could ask what your country would have been like if some historical event didn't happen, and get multiple AI perspectives at once.

One significant advantage of this approach is cost efficiency. Purchasing API tokens can sometimes be more economical than paying standard monthly subscription fees, depending on your usage patterns.

How to Access Multiple AI Models from One Self-Hosted Interface

Step 1: Choose Your Hosting Method

  • Cloud Option: Set up a VPS (Virtual Private Server) on a hosting provider

    • Recommended: KVM2 plan with 8GB RAM and NVMe storage
    • Consider a 12-month term for better pricing
  • On-Premises Option: Host on your own hardware (laptop, NAS, Raspberry Pi)

Step 2: Set Up the Server with OpenWebUI

  1. If using a cloud provider like Hostinger.com:

    • Select "Applications" during setup
    • Choose Llama as application (includes OpenWebUI)
    • Set a secure root password
    • Wait for server deployment (usually a few minutes)
  2. Once deployed:

    • Access the server management page
    • Click "Manage" then "Manage App"
    • This opens OpenWebUI running on port 8080

Step 3: Create Your Admin Account

  1. Click "Get Started" on the OpenWebUI welcome page
  2. Create your admin account with full privileges

Step 4: Connect to AI Providers via API Keys

  1. For OpenAI (ChatGPT):

    • Go to openai.com/api and sign up/sign in
    • Add a payment method (you'll only be charged for what you use)
    • Add $5 credit to start
    • Go to Settings → API Keys → Create new secret key
    • Copy the API key
    • In OpenWebUI, go to Profile → Admin Panel → Settings → Connections
    • Paste your OpenAI API key and save
  2. For more AI providers (Claude, Gemini, Grok, etc.):

    • Install LiteLLM as a proxy server
    • SSH into your server or use the browser terminal
    • Run: git clone https://github.com/BerriAI/litellm.git
    • Navigate to the folder: cd litellm
    • Create an env file: nano .env
    • Add two configuration lines:
      LITELLM_MASTER_KEY="sk-randomcharacters"
      LITELLM_SALT_KEY="sk-randomcharacters"
      
    • Save the file (Ctrl+X, Y, Enter)
    • Run: docker-compose up -d
    • Access LiteLLM interface at your-ip-address:4000
    • Log in with username "admin" and the master key you created

Step 5: Add Models to LiteLLM

  1. In LiteLLM admin panel, go to "Models"
  2. Click "Add Model"
  3. Select provider (Anthropic, Google, OpenAI, etc.)
  4. Choose specific models you want to use
  5. Enter your API key for that provider
  6. Click "Add Model"

Step 6: Create Virtual API Keys

  1. In LiteLLM, go to "Virtual Keys"
  2. Create a new key
  3. Name it (e.g., "kids", "employees")
  4. Select which models this key can access
  5. Set a monthly budget limit if desired
  6. Copy the generated key

Step 7: Connect OpenWebUI to LiteLLM

  1. In OpenWebUI, go to Admin Panel → Settings → Connections
  2. Add your LiteLLM virtual API key under OpenAI API
  3. Set the base URL to: http://localhost:4000 (if hosted on same server)
  4. Click "Verify Connection" then "Save"

Step 8: Create User Accounts & Set Permissions

  1. In OpenWebUI, go to Admin Panel → Settings → Users
  2. Create groups (e.g., "kids", "employees")
  3. Create user accounts and assign them to groups
  4. Set permissions for each group:
    • Which models they can access
    • Whether they can use tools/plugins
    • Access to knowledge bases
  5. Add system prompts to models for safety (e.g., prevent homework cheating)

Monitor Usage and Set Budgets

  • Check the LiteLLM "Usage" tab to monitor spending
  • Set budget limits on virtual API keys to prevent overspending
  • Review conversation logs through the OpenWebUI admin panel

Important Considerations

  • Be aware of token pricing (pay-per-use model)
  • Different models have different pricing (GPT-4.5 is much more expensive than GPT-3.5)
  • Long conversations use more tokens as context is maintained
  • Monitor usage to avoid unexpected costs

All rights reserved.