Guideschevron_rightServers

Servers · 8 min read · Updated

How to Serve an LLM API on a GPU Server with vLLM or Ollama

To serve your own LLM behind an OpenAI-compatible API, install the NVIDIA driver and Container Toolkit, then run vLLM from its vllm/vllm-openai Docker image with the model name and an API key, or install Ollama for a simpler single-user setup. Keep the port bound to the server, put HTTPS in front, and point any OpenAI client at your server's /v1 address. The model must fit in GPU memory with room for the context.

vLLM or Ollama

vLLM compared with Ollama for serving a model
AspectvLLMOllama
Best forMany users and requests at onceOne or a few users, quick setup
Model formatHugging Face models (16-bit and quantized)GGUF builds from its library, mostly 4-bit
Throughput under loadHigh: requests are batched togetherLower: built for simplicity
APIOpenAI-compatible, port 8000Its own and OpenAI-compatible, port 11434
NeedsNVIDIA GPU, compute capability 7.5+Runs on GPU or CPU

Start with the NVIDIA driver and Container Toolkit, and check the model fits with how much VRAM a model needs.

1. Run vLLM in Docker

openssl rand -hex 24 > ~/.vllm-key        # your API key
export HF_TOKEN=hf_...                      # only for gated models

docker run -d --name vllm --restart unless-stopped \
    --runtime nvidia --gpus all \
    -v ~/.cache/huggingface:/root/.cache/huggingface \
    --env "HF_TOKEN=$HF_TOKEN" \
    -p 127.0.0.1:8000:8000 \
    --ipc=host \
    vllm/vllm-openai:latest \
    --model Qwen/Qwen3-8B \
    --api-key "$(cat ~/.vllm-key)"

docker logs -f vllm      # wait until the server reports it is ready

The first start downloads the model. --ipc=host gives vLLM the shared memory it needs. With several GPUs, add --tensor-parallel-size 2 (or the number of GPUs) to split the model across them.

2. Test the API

curl http://127.0.0.1:8000/v1/chat/completions \
  -H "Authorization: Bearer $(cat ~/.vllm-key)" \
  -H "Content-Type: application/json" \
  -d '{"model": "Qwen/Qwen3-8B", "messages": [{"role": "user", "content": "Say hello"}]}'

curl -H "Authorization: Bearer $(cat ~/.vllm-key)" http://127.0.0.1:8000/v1/models

From code, use any OpenAI client with the base URL set to your server's /v1 address and the key above. /health answers without a key, for monitoring.

3. Or Use Ollama

curl -fsSL https://ollama.com/install.sh | sh
ollama pull llama3.1:8b
ollama run llama3.1:8b "Say hello"
nvidia-smi        # the ollama process should be using the GPU

Ollama runs as a service and answers on port 11434 on the server itself, with an OpenAI-compatible API under /v1. It has no API keys of its own, so never open that port to the internet; put it behind a proxy that checks a key, or reach it over a VPN.

4. Put HTTPS in Front

sudo apt install -y caddy
sudo tee /etc/caddy/Caddyfile >/dev/null <<'EOF'
llm.example.com {
    reverse_proxy 127.0.0.1:8000
}
EOF
sudo systemctl reload caddy

Point llm.example.com at the server and allow ports 80 and 443. Docker opens published ports past ufw, which is why the commands above bind to 127.0.0.1; see why ufw does not block Docker ports. For a team on fixed addresses, a WireGuard VPN keeps the API off the internet altogether.

Keeping It Running

  • Watch the GPU with nvidia-smi and the engine's logs; vLLM also exposes /metrics for Prometheus.
  • Pin an image version once it works, and update deliberately: new releases can need a newer driver.
  • Prompts and answers stay on your server; keep its logs to what you need.

No GPU yet? Small and quantized models also run on the processor; see running an LLM on a CPU server.

Common Questions

  • Should I use vLLM or Ollama?

    Ollama for the quickest start, one or a few users and quantized models that switch easily. vLLM for serving many requests at once: it batches users together and gets far more throughput from the same GPU. Both offer an OpenAI-compatible API.

  • Will my existing OpenAI code work?

    Mostly. Point the client's base URL at your server (http://your-server:8000/v1 for vLLM, :11434/v1 for Ollama), set the model name to the one you serve and use your own API key. Features beyond chat, completions and embeddings vary by server.

  • Which GPUs does vLLM support?

    vLLM's documentation lists NVIDIA GPUs with compute capability 7.5 or higher, such as the T4, RTX 20 series and newer, A100, L4, H100 and B200, on Linux. Its current releases are built for CUDA 13 and need an NVIDIA driver that supports it.

  • Do I need a Hugging Face token?

    Only for gated models, whose licence you accept on Hugging Face first, such as some Llama releases. Open models download without one. The model files are cached, so they download once.

Plans and prices

Dedicated Servers

Bare-metal servers with full root access, billed monthly.

See all plans
  • AMD Ryzen 9 5950X

    16 Cores · 128 GB RAM · 2x 1TB NVMe

    Ashburn, VA · Dallas, TX · 50 TB transfer · 10 GigE

    $399.00/mo

  • AMD Ryzen 9 9950X

    16 Cores · 192 GB RAM · 2x 2 TB NVMe

    Ashburn, VA · Dallas, TX · 50 TB transfer · 10 GigE

    $669.00/mo

  • AMD EPYC 4585PX

    16 Cores · 128 GB RAM · 2x 6.4TB NVMe Gen4

    Dallas, TX · 200 TB transfer · 50 Gbps

    $849.00/mo

  • AMD EPYC 7443P

    24 Cores · 512 GB RAM · 2x 2TB NVMe

    Dallas, TX · Ashburn, VA · 50 TB transfer · 10 GigE

    $969.00/mo

Keep Reading

All guides