[{"data":1,"prerenderedAt":199},["ShallowReactive",2],{"seo-verification":3,"blog-how-to-host-localai-on-a-vps-ma-en":6,"promo-bar-likely":190},{"google":4,"bing":5},"EycwPY2XMyTkVzas3n1ygeNJFGAH513qrMjfDljzsMQ","",{"key":7,"data":8},"blog-how-to-host-localai-on-a-vps-ma-en",{"id":9,"slug":10,"slugs":11,"title":15,"excerpt":16,"readTime":17,"views":18,"isPinned":19,"noindex":19,"publishedAt":20,"updatedAt":21,"category":22,"categories":28,"featuredImage":30,"bgImage":31,"posterImage":32,"relatedSolution":33,"intro":36,"sections":37,"ctaTitle":140,"ctaBody":141,"ctaButton":142,"ctaUrl":143,"relatedPosts":144},12,"how-to-host-localai-on-a-vps",{"fr":12,"en":10,"ar":13,"es":14},"heberger-localai-vps","كيفية-استضافة-localai-على-خادم-vps","como-alojar-localai-en-un-vps","How to Host LocalAI on a VPS","Deploy LocalAI on your VPS: full Docker Compose setup, GGUF models, gallery, Whisper, embeddings, API key protection, OpenAI SDK connection and troubleshooting.",8,0,false,"2026-06-08T00:00:00+00:00","2026-10-07T23:07:24+00:00",{"id":23,"name":24,"slug":25,"color":26,"icon":27},1,"Artificial Intelligence","intelligence-artificielle","bg-purple-500\u002F10 text-purple-400","ia",[29],{"id":23,"name":24,"slug":25,"color":26,"icon":27},null,"\u002Fblog\u002Fcovers\u002Fbg.svg","\u002Fblog\u002Fcovers\u002Fheberger-localai-vps-poster.svg",{"categorySlug":34,"appSlug":35},"artificial-intelligence","local-ai","LocalAI is an open source, API-compatible replacement for the OpenAI API: chat, embeddings, image and audio generation, all running locally. On your VPS, it becomes a versatile and private AI API that your applications consume without changing their code. This guide covers the full deployment with Docker Compose, loading GGUF models, connecting your applications and troubleshooting the most common errors.",[38,42,52,55,83,86,89,92,95],{"type":39,"title":40,"body":41},"h2","Why self-host LocalAI on a VPS","Where Ollama focuses on text, LocalAI aims for broad compatibility with the OpenAI API: it exposes `\u002Fv1\u002Fchat\u002Fcompletions`, `\u002Fv1\u002Fembeddings`, `\u002Fv1\u002Fimages\u002Fgenerations` and even audio transcription, on a single API. For a team that already has code written against the OpenAI SDK, LocalAI is a near-transparent replacement: you change the base URL and the key, the rest works. On a VPS, you get this versatility without external dependency or per-call cost. This is especially relevant when you need text generation, vectors for RAG and, occasionally, images all at once, without multiplying providers and keys.",{"type":43,"title":44,"items":45},"ul","The concrete benefits of a self-hosted LocalAI",[46,47,48,49,50,51],"Drop-in replacement for the OpenAI API: no rewriting of the client code.","A single API for chat, embeddings, images and audio.","Support for multiple backends (llama.cpp, diffusers, whisper) under a unified interface.","Open model formats (GGUF) that are downloadable and interchangeable.","No usage-based billing: a fixed VPS cost for all types of generation.","Data and generations kept entirely on your server.",{"type":39,"title":53,"body":54},"Hardware and software requirements","Since LocalAI is versatile, its needs depend on the functions enabled. The figures below are measured minimums — a more powerful VPS reduces response times but does not change feasibility.\n\n**Text only, CPU, 7B model (e.g. Mistral-7B-GGUF)**: 8 GB of RAM, 4 vCPU, 30 GB of disk. At this size, a `\u002Fv1\u002Fchat\u002Fcompletions` call takes 5 to 15 seconds depending on the quantization (Q4 is the standard trade-off). A 3B model fits in 4 GB of RAM.\n\n**Text + images (7B + Stable Diffusion)**: 16 GB of RAM, GPU recommended, 50 GB of disk. Without a GPU, generating one image takes several minutes on a CPU — prefer a GPU VPS for regular use and the `SINGLE_ACTIVE_BACKEND=true` option to avoid saturation when mixing chat and images on the same CPU host.\n\n**Required software**: Docker 24+ and Docker Compose v2 (`docker compose` without a hyphen), a dedicated subdomain (e.g. `ia.your-domain.com`), port 443 open, a DNS record pointing to the VPS IP.",{"type":56,"title":57,"steps":58},"steps","Deploy LocalAI with Docker Compose and HTTPS",[59,62,65,68,71,74,77,80],{"title":60,"body":61},"Prepare the directory structure","Over SSH: `mkdir -p \u002Fopt\u002Flocalai\u002F{models,config} && cd \u002Fopt\u002Flocalai`. The `models` folder will receive GGUF files; `config` will receive the YAML manifests that describe each model to LocalAI.",{"title":63,"body":64},"Create the docker-compose.yaml file","Create `\u002Fopt\u002Flocalai\u002Fdocker-compose.yaml` with the following content:\n\n```yaml\nservices:\n  localai:\n    image: localai\u002Flocalai:latest-cpu\n    restart: unless-stopped\n    ports:\n      - \"127.0.0.1:8080:8080\"\n    volumes:\n      - .\u002Fmodels:\u002Fbuild\u002Fmodels\n      - .\u002Fconfig:\u002Fbuild\u002Fmodels\n    environment:\n      - MODELS_PATH=\u002Fbuild\u002Fmodels\n      - SINGLE_ACTIVE_BACKEND=true\n      - API_KEY=your-secret-key\n    healthcheck:\n      test: [\"CMD\", \"curl\", \"-f\", \"http:\u002F\u002Flocalhost:8080\u002Freadyz\"]\n      interval: 30s\n      retries: 3\n```\n\nReplace `latest-cpu` with `latest-gpu-nvidia-cuda-12` if your VPS has an NVIDIA GPU. `API_KEY` enables token protection on all endpoints — without this variable, the API is accessible without authentication.",{"title":66,"body":67},"Start the container","Run `docker compose up -d`, then follow the startup logs: `docker compose logs -f localai`. Wait for the message `LocalAI API is listening on [::]:8080` before continuing.",{"title":69,"body":70},"Download a first model via the gallery","The LocalAI gallery groups over 200 pre-configured models. To install quantized Mistral-7B-Instruct Q4:\n\n```bash\ncurl http:\u002F\u002F127.0.0.1:8080\u002Fmodels\u002Fapply \\\n  -H 'Authorization: Bearer your-secret-key' \\\n  -d '{\"id\": \"huggingface@thebloke__mistral-7b-instruct-v0.2-gguf\u002Fmistral-7b-instruct-v0.2.Q4_K_M.gguf\"}'\n```\n\nTrack progress: `curl http:\u002F\u002F127.0.0.1:8080\u002Fmodels\u002Fjobs\u002F\u003Cjob-id>`. The GGUF is downloaded into `.\u002Fmodels\u002F` and its YAML manifest is created automatically in `.\u002Fconfig\u002F`.",{"title":72,"body":73},"Add an embeddings model","For RAG, install `all-MiniLM-L6-v2` (84 MB, 256 MB of RAM):\n\n```yaml\n# config\u002Fall-minilm.yaml\nname: all-minilm\nbackend: bert-embeddings\nparameters:\n  model: all-MiniLM-L6-v2.gguf\n```\n\nDownload the GGUF manually into `.\u002Fmodels\u002F` from HuggingFace, then restart: `docker compose restart localai`. Verify with `curl http:\u002F\u002F127.0.0.1:8080\u002Fv1\u002Fmodels`.",{"title":75,"body":76},"Enable Whisper for audio transcription","Add `config\u002Fwhisper.yaml`:\n\n```yaml\nname: whisper-1\nbackend: whisper\nparameters:\n  model: whisper-base.en\n```\n\nThe whisper-base model (~142 MB) is downloaded automatically on the first call. Test with:\n\n```bash\ncurl http:\u002F\u002F127.0.0.1:8080\u002Fv1\u002Faudio\u002Ftranscriptions \\\n  -H 'Authorization: Bearer your-secret-key' \\\n  -F file=@audio.mp3 -F model=whisper-1\n```",{"title":78,"body":79},"Configure Nginx reverse proxy and SSL","Create `\u002Fetc\u002Fnginx\u002Fsites-available\u002Flocalai`:\n\n```nginx\nserver {\n  listen 443 ssl;\n  server_name ia.your-domain.com;\n  ssl_certificate \u002Fetc\u002Fletsencrypt\u002Flive\u002Fia.your-domain.com\u002Ffullchain.pem;\n  ssl_certificate_key \u002Fetc\u002Fletsencrypt\u002Flive\u002Fia.your-domain.com\u002Fprivkey.pem;\n  location \u002F {\n    proxy_pass http:\u002F\u002F127.0.0.1:8080;\n    proxy_read_timeout 300s;\n    proxy_send_timeout 300s;\n  }\n}\n```\n\nObtain the certificate with `certbot certonly --nginx -d ia.your-domain.com`, then `nginx -s reload`. The high timeout is necessary for long inferences on CPU.",{"title":81,"body":82},"Test the API over HTTPS","Validate the complete deployment:\n\n```bash\ncurl https:\u002F\u002Fia.your-domain.com\u002Fv1\u002Fchat\u002Fcompletions \\\n  -H 'Authorization: Bearer your-secret-key' \\\n  -H 'Content-Type: application\u002Fjson' \\\n  -d '{\"model\": \"mistral-7b-instruct-v0.2.Q4_K_M\", \"messages\": [{\"role\": \"user\", \"content\": \"Hello\"}]}'\n```\n\nA JSON response with a `choices` field confirms the deployment is working correctly.",{"type":84,"body":85},"tip","Only enable the backends you need. Loading a chat model, an embedding model and Stable Diffusion simultaneously on a CPU VPS saturates the RAM and collapses performance. Set `SINGLE_ACTIVE_BACKEND=true` to keep only one backend resident at a time, and reserve image generation for a GPU VPS if it becomes a regular use.",{"type":39,"title":87,"body":88},"Choosing and loading your models","LocalAI supports several formats, but the **GGUF** format (produced by llama.cpp) is the recommended standard for CPU: it is quantized (reduces RAM usage), portable and well supported by the gallery.\n\n**GGUF vs other formats**: GGUF formats are the only ones directly loadable via `llama.cpp` without prior conversion. Diffusers models (images) and ONNX (lightweight embeddings) have their own backends and are not interchangeable with GGUFs.\n\n**Gallery vs manual download**: the gallery is the simplest option — it downloads the GGUF and automatically generates the configuration YAML. For a model not listed in the gallery (a fine-tuned model, a custom GGUF), drop the file into `.\u002Fmodels\u002F` and create the YAML manually:\n\n```yaml\nname: my-model\nbackend: llama\nparameters:\n  model: my-model.Q4_K_M.gguf\ncontext_size: 4096\n```\n\n**List loaded models**:\n\n```bash\ncurl https:\u002F\u002Fia.your-domain.com\u002Fv1\u002Fmodels \\\n  -H 'Authorization: Bearer your-secret-key'\n```\n\nModels whose YAML is present in `.\u002Fconfig\u002F` appear in the list, even if their GGUF has not yet been downloaded — in that case, the first call triggers the download.",{"type":39,"title":90,"body":91},"Connecting your applications to LocalAI","Since LocalAI is compatible with the OpenAI API, migrating an existing application comes down to two changes: the base URL and the key.\n\n**Python (openai SDK)**:\n\n```python\nimport openai\n\nclient = openai.OpenAI(\n    base_url=\"https:\u002F\u002Fia.your-domain.com\u002Fv1\",\n    api_key=\"your-secret-key\"\n)\n\nresponse = client.chat.completions.create(\n    model=\"mistral-7b-instruct-v0.2.Q4_K_M\",\n    messages=[{\"role\": \"user\", \"content\": \"Summarize this text: ...\"}]\n)\nprint(response.choices[0].message.content)\n```\n\n**Node.js (openai SDK)**:\n\n```javascript\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n  baseURL: 'https:\u002F\u002Fia.your-domain.com\u002Fv1',\n  apiKey: 'your-secret-key'\n});\n\nconst completion = await client.chat.completions.create({\n  model: 'mistral-7b-instruct-v0.2.Q4_K_M',\n  messages: [{ role: 'user', content: 'Hello' }]\n});\nconsole.log(completion.choices[0].message.content);\n```\n\n**Direct curl**:\n\n```bash\ncurl https:\u002F\u002Fia.your-domain.com\u002Fv1\u002Fembeddings \\\n  -H 'Authorization: Bearer your-secret-key' \\\n  -H 'Content-Type: application\u002Fjson' \\\n  -d '{\"model\": \"all-minilm\", \"input\": \"Text to vectorize\"}'\n```\n\nLangChain, LlamaIndex and most RAG frameworks accept an `openai_api_base` or `base_url` parameter — the change is identical.",{"type":39,"title":93,"body":94},"Troubleshooting: common errors","**`404 model not found` or `model not loaded`**: the model name passed in `model:` does not match any YAML manifest in `.\u002Fconfig\u002F`. Check with `GET \u002Fv1\u002Fmodels`: the displayed name must be used exactly as shown. If the model does not appear, verify the YAML is in the mounted folder and restart the container.\n\n**Very slow inference or `killed` (OOM)**: the model exceeds available RAM. A 7B Q4 model requires approximately 6 GB of free RAM at load time. Check with `docker stats localai` during an inference. Solutions: switch to a lighter quantization (Q3_K_S or Q2_K), reduce the `context_size` in the YAML, or upgrade the VPS.\n\n**`SINGLE_ACTIVE_BACKEND error`**: LocalAI is configured with `SINGLE_ACTIVE_BACKEND=true` and a request attempts to load a second model while another is active. This is the expected behavior on CPU. Wait for the first inference to finish, or disable the option if your VPS has enough RAM for multiple simultaneous models.\n\n**GPU not detected (`CUDA device not found`)**: verify you are using the `latest-gpu-nvidia-cuda-12` image, that the NVIDIA driver is installed on the host (`nvidia-smi`), and that the container has GPU access (`gpus: all` in `docker-compose.yaml` under the `deploy:` key). Without all three conditions, LocalAI silently falls back to CPU.\n\n**`401 Unauthorized`**: the `API_KEY` variable is set in `docker-compose.yaml` but the `Authorization: Bearer \u003Ckey>` header is missing or incorrect in the call. All endpoints, including `\u002Fv1\u002Fmodels`, require the header once `API_KEY` is set.",{"type":96,"title":97,"headers":98,"rows":102},"comparison","LocalAI vs Ollama vs vLLM: which LLM server to choose?",[5,99,100,101],"LocalAI","Ollama","vLLM",[103,107,111,115,118,121,126,131,135],[104,105,105,106],"GPU required","No (CPU by default)","Yes (GPU mandatory)",[108,109,110,109],"OpenAI-compatible API","Yes (complete)","Yes (partial)",[112,113,114,114],"Image generation","Yes (Stable Diffusion)","No",[116,117,114,114],"Audio transcription","Yes (Whisper)",[119,120,120,120],"Native embeddings","Yes",[122,123,124,125],"Model library","200+ GGUF models","Curated model list","HuggingFace models",[127,128,129,130],"Throughput (tokens\u002Fs, 7B)","~10-20 CPU \u002F ~80+ GPU","~15-25 CPU \u002F ~80+ GPU","~150+ GPU only",[132,133,133,134],"RAM (7B Q4 model)","~6 GB","~14 GB (FP16)",[136,137,138,139],"Main use case","Unified multi-modal API","Simple text inference","High-performance production","A complete and private AI API on a ServOrbit Cloud VPS","With a ServOrbit Cloud VPS and preconfigured Docker, deploy LocalAI as a private alternative to the OpenAI API. Choose a CPU or GPU configuration according to your chat, embeddings or image needs.","Start my Cloud VPS","\u002Fvps-cloud",[145,162,180],{"id":23,"slug":146,"slugs":147,"title":151,"excerpt":152,"readTime":153,"views":23,"isPinned":19,"noindex":19,"publishedAt":154,"updatedAt":155,"category":156,"categories":157,"featuredImage":30,"bgImage":31,"posterImage":159,"relatedSolution":160},"how-to-host-open-webui-on-a-vps",{"fr":148,"en":146,"ar":149,"es":150},"heberger-open-webui","كيفية-استضافة-open-webui-على-خادم-vps","como-alojar-open-webui-en-un-vps","How to Host Open WebUI on a VPS","A complete guide to deploying Open WebUI on your own VPS. Keep control of your data, avoid cloud API costs, and access your LLMs from a clean web interface.",9,"2026-06-01T00:00:00+00:00","2026-11-09T20:55:18+00:00",{"id":23,"name":24,"slug":25,"color":26,"icon":27},[158],{"id":23,"name":24,"slug":25,"color":26,"icon":27},"\u002Fblog\u002Fcovers\u002Fheberger-open-webui-poster.svg",{"categorySlug":34,"appSlug":161},"open-webui",{"id":163,"slug":164,"slugs":165,"title":169,"excerpt":170,"readTime":171,"views":23,"isPinned":19,"noindex":19,"publishedAt":172,"updatedAt":173,"category":174,"categories":175,"featuredImage":30,"bgImage":31,"posterImage":177,"relatedSolution":178},2,"deploying-dify-on-a-vps-ai-workflows-under-control",{"fr":166,"en":164,"ar":167,"es":168},"deployer-dify-vps","نشر-dify-على-vps-سير-عمل-الذكاء-الاصطناعي-تحت-السيطرة","desplegar-dify-en-un-vps","Deploy Dify on a VPS: Complete Guide from Installation to Plugins","Install Dify on a ServOrbit VPS: requirements, Docker Compose, offline plugins, known Docker limits, backup before upgrading, and troubleshooting.",15,"2026-02-11T00:00:00+00:00","2026-10-29T03:10:23+00:00",{"id":23,"name":24,"slug":25,"color":26,"icon":27},[176],{"id":23,"name":24,"slug":25,"color":26,"icon":27},"\u002Fblog\u002Fcovers\u002Fdeployer-dify-vps-poster.svg",{"categorySlug":25,"appSlug":179},"dify",{"id":181,"slug":182,"slugs":183,"title":187,"excerpt":188,"readTime":189,"views":23,"isPinned":19,"noindex":190,"publishedAt":191,"updatedAt":192,"category":193,"categories":194,"featuredImage":30,"bgImage":31,"posterImage":196,"relatedSolution":197},121,"hosting-openclaw-on-a-vps",{"fr":184,"en":182,"ar":185,"es":186},"heberger-openclaw-vps","استضافة-openclaw-على-خادم-vps","alojar-openclaw-en-un-vps","Hosting OpenClaw on a VPS","Host OpenClaw on your VPS: the open source personal AI assistant reachable from WhatsApp, Telegram, Discord and 50+ messaging apps. Docker, LLM setup and HTTPS.",4,true,"2026-02-23T00:00:00+00:00","2026-11-09T20:55:19+00:00",{"id":23,"name":24,"slug":25,"color":26,"icon":27},[195],{"id":23,"name":24,"slug":25,"color":26,"icon":27},"\u002Fblog\u002Fcovers\u002Fheberger-openclaw-vps-poster.svg",{"categorySlug":34,"appSlug":198},"openclaw",1794270426346]