Blog / Tutorials

LiteLLM on a VPS: One API Endpoint for Every LLM Provider

By the NoctHost TeamJuly 3, 20262 min read

If you're using more than one LLM provider — OpenAI for some tasks, Anthropic for others, a local Ollama model for cost-sensitive workloads — your codebase starts looking like a mess of different SDKs, API keys, and endpoint formats.

LiteLLM solves this. It's an open-source proxy that sits in front of all your LLM providers and exposes a single OpenAI-compatible API endpoint. Your application calls one URL, LiteLLM routes the request to whichever provider you configure.

What LiteLLM Does

  • Single OpenAI-compatible endpoint for 100+ providers
  • Route requests between providers based on model name
  • Track costs per model, per team, per API key
  • Set spending limits and rate limits
  • Fall back to backup providers if primary fails
  • Load balance across multiple deployments

What You Need

  • A VPS with at least 2 GB RAM
  • Docker installed
  • API keys for whichever providers you want to use

Step 1: Create the Configuration File

mkdir ~/litellm && cd ~/litellm
nano config.yaml
model_list:
  - model_name: gpt-4o
    litellm_params:
      model: openai/gpt-4o
      api_key: os.environ/OPENAI_API_KEY

  - model_name: claude-sonnet
    litellm_params:
      model: anthropic/claude-sonnet-4-6
      api_key: os.environ/ANTHROPIC_API_KEY

  - model_name: local-llama
    litellm_params:
      model: ollama/llama3.1:8b
      api_base: http://host.docker.internal:11434

general_settings:
  master_key: your-master-key-here

Step 2: Deploy with Docker

nano docker-compose.yml
version: '3.8'
services:
  litellm:
    image: ghcr.io/berriai/litellm:main-latest
    restart: always
    ports:
      - "4000:4000"
    volumes:
      - ./config.yaml:/app/config.yaml
    environment:
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
      - LITELLM_MASTER_KEY=${LITELLM_MASTER_KEY}
    command: --config /app/config.yaml --port 4000
    extra_hosts:
      - "host.docker.internal:host-gateway"

Create a .env file:

OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
LITELLM_MASTER_KEY=your-master-key-here
docker compose up -d

Step 3: Test the Endpoint

curl http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-master-key-here" \
  -d '{
    "model": "local-llama",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Switch models by changing the model name — same endpoint, same format.

Step 4: Expose with Nginx and HTTPS

apt install -y nginx certbot python3-certbot-nginx
nano /etc/nginx/sites-available/litellm
server {
    server_name llm.yourdomain.com;

    location / {
        proxy_pass http://localhost:4000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
ln -s /etc/nginx/sites-available/litellm /etc/nginx/sites-enabled/
certbot --nginx -d llm.yourdomain.com
nginx -t && systemctl reload nginx

The Cost Tracking Dashboard

LiteLLM ships with a built-in dashboard at /ui. Log in with your master key to see spend per model, per virtual key, and per team. Set budget limits to prevent runaway costs.

What it costs

LiteLLM is a lightweight proxy, so it barely uses resources itself; the heavy lifting stays with whichever provider you route to. The Micro plan (1 vCPU, 1 GB) runs it fine as a single gateway for your team. NoctHost bills hourly from a prepaid balance you top up with crypto, with no card and no KYC.

Spin one up in about a minute

Email signup, pay with crypto, hourly billing. Trying a box costs cents — destroy it when you are done.

Deploy a server

Frequently asked

Can I use LiteLLM with my existing OpenAI SDK code?
Yes. Just change the base_url to your LiteLLM endpoint and the api_key to your master key. Everything else stays identical.
Does LiteLLM add latency?
Minimal — a few milliseconds of proxy overhead. For most applications this is unnoticeable.
Can I create separate API keys for different applications?
Yes. LiteLLM supports virtual keys with individual rate limits and spending caps. Create them in the dashboard or via the API.

Keep reading