Skip to content

How to Deploy LocalAI on a VPS

Updated Sep 2026

verified on Ubuntu 26.04 · Aug 2026
We earn commissions when you shop through the links below. Full disclosure →

Self-host LocalAI on your own VPS — a drop-in OpenAI API replacement with support for multiple model formats, audio, image, and embedding generation.

Before you start
  • A VPS with 8+ GB RAM (16 GB recommended for 7B models)
  • A fresh Ubuntu 26.04 server with root/sudo SSH access
  • Optional: NVIDIA GPU for acceleration (CPU-only works for smaller models)
Need a box for this guide? Kamatera's free tier lets you spin one up now.Start free on Kamatera → (opens in new tab)

What LocalAI is

LocalAI is a drop-in replacement for OpenAI's API that runs entirely on your own hardware. It's designed to be wire-compatible with OpenAI's endpoints — swap the base URL in any OpenAI-compatible client and it works with local models. But LocalAI goes beyond text generation: it supports image generation (Stable Diffusion), audio transcription (Whisper), text-to-speech, and embeddings, all through the same API surface.

The appeal is API compatibility without the cloud. Many AI tools and frameworks are built around OpenAI's API format. LocalAI lets you run those tools against local models without modifying a single line of code. Your prompts, images, and audio never leave your server.

LocalAI supports multiple model formats — GGML, GGUF, GPTQ, and more — and can load models from Hugging Face, manual downloads, or its own model hub. It's more flexible than Ollama in terms of model format support, though Ollama is simpler for basic LLM usage.

Server sizing — more formats, more memory

LocalAI's memory requirements depend on which features you use. Text models follow the same sizing as Ollama (model weights must fit in RAM/VRAM), but image and audio models add their own overhead.

Text-only (LLM inference):

  • 8 GB RAM — small models (3B), tight context
  • 16 GB RAM — 7B models with reasonable context
  • 32+ GB RAM — 13B+ models or concurrent requests

With image generation (Stable Diffusion):

  • 16 GB RAM minimum — the image model itself is 2-4 GB, plus the text model
  • GPU strongly recommended — image generation on CPU is painfully slow (minutes per image vs seconds on GPU)

With audio features (Whisper/TTS):

  • 8 GB RAM — Whisper is relatively light (1-2 GB for the base model)
  • 4 GB RAM — text-to-speech models are small

The practical minimum for a full-featured LocalAI setup is 16 GB RAM with a GPU for reasonable image generation performance. An 8 vCPU / 16 GB VPS is the floor; for GPU acceleration, you need a GPU instance.

Prepare the server

Start from a fresh Ubuntu 24.04 or 26.04 server. Update and create a non-root user:

apt update && apt upgrade -y
adduser deploy
usermod -aG sudo deploy

Lock down the firewall:

ufw allow OpenSSH
ufw allow 80
ufw allow 443
ufw enable

Install Docker:

curl -fsSL https://get.docker.com | sh
usermod -aG docker deploy

Log out and back in as deploy so the docker group takes effect.

Where to host itaffiliate disclosure
Hetzner Cloudrun it on
2 vCPU · 4 GB RAM · 80 GB SSD · $23.59/mo
Get Hetzner Cloud (opens in new tab)
Kamaterafree trial
1 vCPU · 1 GB RAM · 20 GB SSD · $4.00/mo
Start free on Kamatera → (opens in new tab)
DigitalOceanalso works on
1 vCPU · 1 GB RAM · 25 GB SSD · $6.00/mo
Deploy on DigitalOcean → (opens in new tab)

Paid link — we earn a commission if you shop through it.

Install LocalAI

Create a working directory:

mkdir ~/localai && cd ~/localai

Create a compose file:

services:
  localai:
    image: localai/localai:latest
    restart: unless-stopped
    ports:
      - "127.0.0.1:8080:8080"
    volumes:
      - localai_models:/models
    environment:
      - THREADS=4
      - CONTEXT_SIZE=2048
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]  # comment out if no GPU

volumes:
  localai_models:

The THREADS setting controls CPU usage — set it to your vCPU count. CONTEXT_SIZE controls how much text the model can handle in a single request.

Start it:

docker compose up -d

LocalAI listens on port 8080. The 127.0.0.1 bind keeps it private.

GPU support

If you have an NVIDIA GPU, install the NVIDIA Container Toolkit first (same as the Ollama guide):

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
  gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
  sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
  tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt update
apt install -y nvidia-container-toolkit
nvidia-ctk runtime configure --runtime=docker
systemctl restart docker

Without a GPU, remove the deploy.resources section — LocalAI falls back to CPU inference.

Download models

LocalAI needs models to serve. You can download them from Hugging Face, the LocalAI model hub, or manually place them in the models volume.

Using the LocalAI CLI:

# Download a text model (GGUF format)
docker exec -it localai local-ai model download --name hermes-3-llama-3.1-8b

# Download an embedding model
docker exec -it localai local-ai model download --name text-embedding-ada-002

# Download a Whisper model for audio transcription
docker exec -it localai local-ai model download --name whisper-1

Manual download:

# Download a model directly to the volume
docker exec -it localai wget -O /models/my-model.gguf \
  https://huggingface.co/TheBloke/Hermes-3-Llama-3.1-8B-GGUF/resolve/main/hermes-3-llama-3.1-8b.Q4_K_M.gguf

List available models:

curl http://localhost:8080/v1/models

HTTPS + domain

LocalAI's API should not face the internet without TLS. Point a reverse proxy at 127.0.0.1:8080 and terminate HTTPS on 443.

The simplest path is Automatic HTTPS with Caddy. Point an A record for your hostname (say ai.example.com) at the server's public IP, then have Caddy reverse-proxy that hostname to 127.0.0.1:8080.

If you're using the Caddy container approach, put LocalAI and Caddy in the same compose file and proxy to the LocalAI service name:

reverse_proxy localai:8080

Using the API

LocalAI's API is wire-compatible with OpenAI's. Point any OpenAI client at your endpoint:

  • Base URL: https://ai.example.com/v1
  • API Key: anything (LocalAI doesn't validate keys by default, but you can set one)

Examples with curl:

# Chat completion
curl https://ai.example.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "hermes-3-llama-3.1-8b",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

# Image generation
curl https://ai.example.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -d '{
    "model": "stablediffusion",
    "prompt": "a sunset over mountains"
  }'

# Audio transcription
curl https://ai.example.com/v1/audio/transcriptions \
  -F file=@audio.mp3 \
  -F model=whisper-1

# List available models
curl https://ai.example.com/v1/models

Tools like Open WebUI, LibreChat, and AnythingLLM can all point at this endpoint. If you're building your own app, the OpenAI SDK works with LocalAI by changing the base URL.

Backups

LocalAI's state is primarily the downloaded models in the /models volume. Models are re-downloadable, so you don't strictly need to back them up. If you've customized model configurations, back up the data volume:

docker run --rm -v localai_models:/data -v $(pwd):/backup alpine \
  tar czf /backup/localai-$(date +%F).tar.gz -C /data .

For a complete backup including all models:

docker run --rm -v localai_models:/data -v $(pwd):/backup alpine \
  tar czf /backup/localai-full-$(date +%F).tar.gz -C /data .

Upgrades

Pull the newer image and recreate:

docker compose pull
docker compose up -d

LocalAI updates are usually non-breaking. Check the LocalAI changelog for any notable changes.

Troubleshooting

Model download fails. Check disk space and network connectivity. Models can be several GB, and the download may time out on slow connections. Try downloading manually to the models volume.

Out of memory during inference. The model is too large for your RAM. Use a smaller model or a more aggressive quantization. Check docker logs localai for memory errors.

GPU not detected. Verify the NVIDIA Container Toolkit is installed and Docker can see the GPU: docker run --rm --gpus all nvidia/cuda:12.0-base nvidia-smi. If that fails, re-run the toolkit installation.

Slow responses on CPU. Expected without a GPU. Image generation in particular is 10-50x slower on CPU. For better performance, add a GPU or use a smaller model.

API returns errors about missing model. The model name must match exactly what you downloaded. Check available models with curl http://localhost:8080/v1/models.

Image generation fails. Stable Diffusion models require significant RAM and ideally a GPU. If you're on CPU-only, image generation may timeout or produce poor results. Consider using a smaller image model or a remote backend for image tasks.

Verification + next steps

You're done when you can: load the API over HTTPS, make chat completion requests, generate images, transcribe audio, and get coherent responses. The API should work with any OpenAI-compatible client.

From here, explore LocalAI's advanced features like voice cloning, function calling, and custom model configurations. For a simpler text-only setup, see Ollama. For a web interface, pair LocalAI with Open WebUI. An 8 vCPU / 16 GB box is the minimum for a full-featured setup; a GPU instance is the step up. See Best VPS for AI & ML Workloads for the ranked picks.

Next steps

How to self-host LocalAI →More self-hosted ai chat interfaces tools →Best VPS for AI & LLM Apps →Automatic HTTPS with Caddy →Run Claude Code with Ollama on Your Own VPS →Deploy Coolify on a VPS →How to Deploy Actual Budget on a VPS →How to Deploy AnythingLLM on a VPS →How to Deploy Appwrite on a VPS →How to Deploy Audiobookshelf on a VPS →How to Deploy Authelia on a VPS →How to Deploy authentik on a VPS →How to Deploy Baserow on a VPS →How to Deploy Beszel on a VPS →How to Deploy Bitwarden on a VPS →How to Deploy BookStack on a VPS →How to Deploy CapRover on a VPS →How to Deploy Checkmate on a VPS →How to Deploy Directus on a VPS →How to Deploy docker-mailserver on a VPS →How to Deploy Docmost on a VPS →How to Deploy Dokku on a VPS →How to Deploy Dokploy on a VPS →How to Deploy Firefly III on a VPS →How to Deploy Forgejo on a VPS →How to Deploy Gatus on a VPS →How to Deploy Ghostfolio on a VPS →How to Deploy Gitea on a VPS →How to Deploy GitLab on a VPS →How to Deploy GlitchTip on a VPS →How to Deploy Grafana on a VPS →How to Deploy Graylog on a VPS →How to Deploy Headscale on a VPS →How to Deploy Healthchecks on a VPS →How to Deploy Home Assistant on a VPS →How to Deploy Immich on a VPS →How to Deploy Jan on a VPS →How to Deploy Jellyfin on a VPS →How to Deploy Karakeep on a VPS →How to Deploy Keycloak on a VPS →How to Deploy Leantime on a VPS →How to Deploy LibreChat on a VPS →How to Deploy Linkwarden on a VPS →How to Deploy Mailcow on a VPS →How to Deploy Mailu on a VPS →How to Deploy Matomo on a VPS →How to Deploy Mattermost on a VPS →How to Deploy Meilisearch on a VPS →How to Deploy Memos on a VPS →How to Deploy n8n on a VPS →How to Deploy Navidrome on a VPS →How to Deploy NetBird on a VPS →How to Deploy Netdata on a VPS →How to Deploy Nextcloud on a VPS →How to Deploy Next.js to a VPS →How to Deploy Nginx Proxy Manager on a VPS →How to Deploy NocoDB on a VPS →How to Deploy ntfy on a VPS →How to Deploy Ollama on a VPS →How to Deploy Open WebUI on a VPS →How to Deploy OpenHands on a VPS →How to Deploy OpenObserve on a VPS →How to Deploy OpenProject on a VPS →How to Deploy Outline on a VPS →How to Deploy Pangolin on a VPS →How to Deploy Paperless-ngx on a VPS →How to Deploy Passbolt on a VPS →How to Deploy Plane on a VPS →How to Deploy Plausible Analytics on a VPS →How to Deploy Pocket ID on a VPS →How to Deploy PocketBase on a VPS →How to Deploy Prometheus on a VPS →How to Deploy Psono on a VPS →How to Deploy Radarr on a VPS →How to Deploy Rocket.Chat on a VPS →How to Deploy SigNoz on a VPS →How to Deploy Sonarr on a VPS →How to Deploy Stalwart on a VPS →How to Deploy Stirling-PDF on a VPS →How to Deploy Supabase on a VPS →How to Deploy Synapse on a VPS →How to Deploy Taiga on a VPS →How to Deploy TeamPass on a VPS →How to Deploy Tinyauth on a VPS →How to Deploy Traefik on a VPS →How to Deploy Trilium on a VPS →How to Deploy Twenty CRM on a VPS →How to Deploy Umami on a VPS →How to Deploy Uptime Kuma on a VPS →How to Deploy Vaultwarden on a VPS →How to Deploy Vikunja on a VPS →How to Deploy wg-easy on a VPS →How to Deploy Wiki.js on a VPS →How to Deploy Zabbix on a VPS →How to Deploy Zitadel on a VPS →How to Deploy Zulip on a VPS →Docker & Compose on Ubuntu 26.04 →Building AI Workflows with n8n →Install Open WebUI with Ollama →Adding AI-Powered Insights to Plausible Analytics →Building AI-Powered Apps with Supabase and pgvector →

We use analytics cookies (Google Analytics, PostHog) to see which guides are useful. No ad networks, no cross-site tracking. See our privacy policy.