To install LocalAI, use Docker Compose: download the official docker-compose.yaml, run docker compose up -d, open http://localhost:8080, install a small model from Models → Explore, then test /v1/chat/completions. LocalAI is $0 under MIT; in our worked example, 50M input + 10M output tokens a month saves $162/yr in GPT-4o mini API charges before electricity and maintenance.
You already have an app, script, or internal tool that expects an OpenAI-style API. What you do not want is every private prompt leaving your building, or a usage bill that grows each time staff find another job for it.
LocalAI is the self-hosted server built for that gap. This guide shows how to install LocalAI as a self hosted OpenAI alternative, install a first model, test the API, lock the server down, back it up, update it, and fix the errors that stop most first installs. Every command, licence claim, storage path, and price below was checked on official LocalAI or OpenAI pages on 1 December 2026.
Quick Answer
To install LocalAI, use Docker Compose for the most repeatable small-business setup: download the official docker-compose.yaml, run docker compose up -d, open http://localhost:8080, install a small model from Models → Explore, then test /v1/chat/completions. LocalAI is free under the MIT licence. In our worked example, moving 50 million input tokens and 10 million output tokens a month from GPT-4o mini saves $162 a year in API charges before electricity and maintenance.
In this article
- How we checked this guide
- What LocalAI replaces, and what it does not
- Install routes at a glance
- Requirements before you install LocalAI
- Step 1: install LocalAI with Docker Compose
- Step 2: install your first model
- Step 3: test the OpenAI-compatible API
- First-run security steps you must not skip
- Make LocalAI useful: models, backends and clients
- Backup and update routine
- Common errors and fixes
- Tips and tricks that save time
- The real cost maths: LocalAI versus the OpenAI API
- When not to self-host LocalAI
- Pros and cons
- Our verdict
- FAQ
- Strategic Pivot: price the whole stack before you switch
- Sources
How we checked this guide
We checked the install commands on the official LocalAI Quickstart and Containers pages, the security settings on the official Authentication and Authorization page, model storage on the official FAQ, and the diagnostic commands on the official Troubleshooting page. The licence statement comes from LocalAI’s official documentation: LocalAI is open source under the MIT licence.
The paid comparison uses OpenAI’s official GPT-4o mini model page, which lists $0.15 per million input tokens, $0.075 per million cached input tokens, and $0.60 per million output tokens. We also checked ChatGPT Plus at $20 a month on OpenAI’s Help Center, but we do not use it as the main saving because LocalAI replaces an API endpoint, not the ChatGPT app itself. Where LocalAI does not publish a fixed hardware minimum, we say so instead of inventing one.
What LocalAI replaces, and what it does not
LocalAI replaces the hosted API address for compatible workloads. It runs open models for chat, images, speech, video, embeddings, and related tasks on your own machines, and its API speaks the OpenAI and Anthropic formats. That means an OpenAI SDK or client can usually keep its request shape and change its base URL to your LocalAI server.
The practical difference is where the model runs. With a hosted API, the provider runs the model and bills by tokens or another usage unit. With LocalAI, your computer or server runs the model, stores the files, and carries the electricity, storage, update, and downtime risk. LocalAI removes the per-token software bill; it does not remove the need for hardware or administration.
Best for: a small business, freelancer, or developer who needs a private OpenAI-compatible endpoint for internal drafting, classification, document work, embeddings, speech, or a small app, and who can keep one machine or server running. Skip if: you need frontier-model quality on every request, guaranteed uptime for customers, or a tool that needs no technical setup. LocalAI is a server, not a one-click consumer chat subscription.
LocalAI also sits at a different layer from the tools in our earlier guides. Our guide to install Ollama on Ubuntu covers a simpler local model runner. Our guide to install Open WebUI with Ollama covers a browser chat front end. Our guide to install llama.cpp for local LLM on CPU covers the engine layer. Our guides to install GPT4All for private offline AI chat and install Jan AI desktop for local models cover desktop apps. Choose LocalAI when the API server itself is the product you need.
Install routes at a glance
LocalAI gives you several official routes. The right one depends less on fashion and more on how you want to maintain the server.
| Route | Best for | Main trade-off |
|---|---|---|
| Docker Compose | A repeatable server install with named volumes | You must manage Docker and the compose file |
| Install script | A quick Linux or Apple Silicon Mac test | You manage the process and paths yourself |
| Desktop app | Starting and stopping the server from a desktop interface | Less natural for an always-on office server |
| Windows PowerShell script | A native Windows test | Windows service and firewall care still sit with you |
docker run | A short trial or a custom container command | Easy to forget a volume and lose data on recreation |
For a small business, Docker Compose is the safest default in this guide. The official compose file keeps models, backends, settings, and application data in four named volumes, so they remain when you recreate or upgrade the container. It also restarts LocalAI after a crash or reboot. Those two details matter more than saving one command on day one.
Requirements before you install LocalAI
LocalAI does not publish one universal RAM minimum because the model decides the memory bill. A small model and a large model are different purchases wearing the same server name. Plan around the model first, then the server.
You need a machine that can stay on while people or apps use the API. You need internet access for the first downloads: the container image or binary, the model, and the backend that model needs. You need enough free disk for the model plus temporary download space. LocalAI’s FAQ gives useful planning ranges: small 1–3B models are about 1–3 GB, medium 7–13B models about 4–8 GB, and large 30B+ models 15–30+ GB. It recommends at least 2–3 times the model size available for downloads and temporary files, and SSD storage for better performance.
The official Quickstart’s suggested first model, gemma-4-e2b-it-qat-q4_0, downloads 4.3 GB in total: 3.35 GB for the model and 0.99 GB for the image projector. That makes it a sensible first test, but you still need headroom beyond 4.3 GB because backends, caches, uploads, and generated files also take space.
A GPU is optional. LocalAI runs on CPU, and a GPU makes it faster. If you use a container GPU image, the image must match the hardware: CPU uses localai/localai:latest; NVIDIA has CUDA 12 and CUDA 13 images; AMD uses the ROCm image; Intel and Vulkan have their own images. Do not install a GPU image and hope the container will sort out missing host drivers. For NVIDIA in Compose, the host needs the NVIDIA Container Toolkit. For AMD, Intel, and Vulkan, the compose file passes the required device files.
Before the first start, decide who may reach port 8080. LocalAI listens on port 8080 on all interfaces, and authentication is off by default. On a private laptop test, that may be acceptable for a few minutes. On an office network or public server, it is the first thing to fix.
Step 1: install LocalAI with Docker Compose
Install Docker first if it is not already present. LocalAI’s container guide lists Docker and Podman as supported container engines. The steps below use Docker Compose because the official compose file already carries the four persistent volumes.
Create a folder for the install, download the official compose file, and start it:
mkdir -p localai
cd localai
curl -fsSL https://localai.io/install/docker-compose.yaml -o docker-compose.yaml
docker compose up -dThen open http://localhost:8080 in your browser. If the page does not load, do not reinstall at random. Check the container and logs first:
docker ps -a
docker logs local-ai
curl http://localhost:8080/readyzThe compose file runs the CPU image by default. That is the correct first test for most readers because it removes GPU variables while you prove the server, model download, and API call. Add a GPU only after the CPU path works, unless you already know the host GPU and driver setup are correct.
To use a GPU in Compose, edit docker-compose.yaml: change image to the tag for your hardware and remove the comment markers from the matching GPU block. For NVIDIA, that block reserves all GPUs and needs the NVIDIA Container Toolkit on the host. For AMD, Intel, and Vulkan, the block passes device files such as /dev/dri, with /dev/kfd also used for AMD. Start again with:
docker compose up -dIf you prefer the script route on Linux or an Apple Silicon Mac, the official Quickstart uses:
curl -sSL https://localai.io/install.sh | sh
local-aiThe script installs the local-ai program but does not start it. Running local-ai starts the server with no model. On Windows, the official PowerShell route is irm https://localai.io/install.ps1 | iex. Use the script for a test; use Compose when the server must survive reboots and upgrades with its data intact.

Step 2: install your first model
A fresh LocalAI server is only the doorway. It still needs a model. Open http://localhost:8080, accept the model recommended by the first-run card, or go to Models → Explore, search for gemma-4-e2b-it-qat-q4_0, and choose Install.
The Quickstart describes this as a small Google Gemma 4 model that runs on a CPU and reads images. The download is 4.3 GB in total. After it installs, open Chats, select the model, type a short message, and send it. On CPU, the first reply takes longer because the model has to load. Judge speed after the second or third reply, not while the model is still loading.
You can also install models from the command line. To list the gallery or install without starting the server:
local-ai models list
local-ai models install <name>To start LocalAI with a named model, use:
local-ai run gemma-4-e2b-it-qat-q4_0LocalAI checks your GPU when you install a model and downloads the matching backend. That backend behaviour is useful, but it also explains why the first model can take longer than later ones: the server may be downloading both the model and the engine pieces it needs.
Start smaller than your ambition. A model that answers reliably is better than a larger model that loads once, exhausts memory, and teaches staff that the private server is broken. Move up only after you know the workload, response time, and failure pattern.
Step 3: test the OpenAI-compatible API
Once the web chat answers, test the API. A working chat window proves the model loads; a working API call proves your app can use the server.
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gemma-4-e2b-it-qat-q4_0",
"messages": [{"role": "user", "content": "Hello!"}]
}'The reply text is in choices[0].message.content. If you have turned on API keys, add the authorization header:
-H "Authorization: Bearer <your-key>"For an existing OpenAI client, point the base URL at LocalAI. Many clients read OPENAI_BASE_URL, so the change is often:
OPENAI_BASE_URL=http://localhost:8080/v1Then confirm the model name your client sends matches a model LocalAI actually has:
curl http://localhost:8080/v1/modelsThat one check prevents the most common false alarm: the server is healthy, the model is installed, but the app asks for a name that does not exist.
First-run security steps you must not skip
LocalAI’s Quickstart states the risk plainly: LocalAI listens on port 8080 on all interfaces, and authentication is off. Protect the API before you expose it beyond your own machine. Treat that sentence as part of the install, not as a later hardening project.

For a single private server, the simplest protection is an API key. Set LOCALAI_API_KEY to a long random value you generate and store in your password manager. Clients then send it as Authorization: Bearer <key>, x-api-key, or xi-api-key. The limit is important: legacy API keys grant full admin access. There is no role separation. Do not hand one shared legacy key to every staff member and call it a permission system.
For a team, use the user authentication system instead. Set LOCALAI_AUTH=true for user accounts, admin and user roles, sessions, OAuth or OIDC options, per-user API keys, and usage tracking. The first registered user becomes admin. LocalAI warns that setting an admin email promotes that address but does not reserve the first-admin role for it. Keep registration inaccessible to other users until bootstrap is complete, register the intended administrator first, and only then invite the team.
Do not enable user authentication casually on an existing anonymous instance. LocalAI states that enabling auth does not assign existing anonymous data to an account. Chats, saved agents, notifications, and files made under the anonymous owner stay separate and no account can see them. Export what you need, back up the data path, test the switch on a copy, and then make the change.
Network placement matters as much as the key. Keep LocalAI on a private network or behind your normal access controls when the workload is internal. Do not publish port 8080 to the internet just because the first test worked. If staff need remote access, give them the authenticated route you already trust for internal tools, and test that an unauthenticated request fails before you call the setup finished.
Make LocalAI useful: models, backends and clients
LocalAI’s core provides the API, routing, web interface, and agents. Each inference backend is separate and is installed only when a model needs it. That design keeps the first install smaller, but it also means model choice and backend choice must agree. A GGUF model for llama.cpp needs the llama-cpp backend; a diffusion model needs a diffusers backend. The official compatibility table is the place to check before you blame the server.
Manage backends deliberately:
local-ai backends list
local-ai backends install llama-cppUse the web interface or CLI to see what is installed before adding more. A small business server does not need every backend. It needs the backend for the one or two models that carry real work.
For clients, change one thing at a time. Point one test script at http://localhost:8080/v1, keep the model name exact, and compare the output with the web chat. If the script fails, read the status code before changing settings. A 401 points to authentication. A 404 model error points to the model name or installed model list. A connection refusal points to the server, port, or container state.
Keep prompts and files inside the same boundary you promised staff. LocalAI’s files and models stay on your machines, but features that call outside services are opt-in. If you enable an outside connector, web search, or another external service, that feature changes the privacy story. Name it, test it, and do not describe the whole setup as offline after turning on an outside call.
Backup and update routine
Back up the four persistent areas, not just the compose file. In the container setup they are /models for model files, /backends for backends, /configuration for dynamic config files such as api_keys.json, external_backends.json, and runtime_settings.json, and /data for collections, chat files, add-ons, generated content, uploads, home folder, and caches. Files outside a volume are lost when the container is recreated during an image upgrade.

A practical routine is simple. Stop or quiet the workload, copy the compose file and the four volumes or bind-mounted folders, record the image tag and LocalAI version, and keep one backup outside the server. Test the restore on a spare machine or spare folder before you need it during a failure. A backup you have never restored is a hope with a filename.
For the container update, LocalAI’s official steps are:
docker compose pull
docker compose up -ddocker compose down stops LocalAI and keeps the volumes. docker compose down -v also deletes the volumes, with all models and data. Never use -v as a casual restart command.
If you use SQLite for authentication, remember the database files travel together. LocalAI uses WAL mode, which adds database.db-wal and database.db-shm beside database.db. Copy or back up all three together, or run the checkpoint the docs describe before copying. Also run one LocalAI process per SQLite database file; use PostgreSQL when more than one instance must share accounts.
Update in a maintenance window, then repeat the same three checks every time: /readyz, /v1/models, and one real chat completion. If the update breaks a backend, your notes should tell you the previous image tag, the model name, and the exact error. That turns a bad morning into a rollback instead of an investigation.
Common errors and fixes
Start with evidence. LocalAI’s troubleshooting guide gives the first checks:
curl http://localhost:8080/readyz
curl http://localhost:8080/v1/models
local-ai --version
docker logs local-ai
docker ps -a | grep local-aiIf the API returns 404 or “model not found,” confirm the model exists and the request name matches. List model IDs with curl http://localhost:8080/v1/models | jq '.data[].id'. Check the models path if the model is missing. A file sitting in the wrong folder is not an installed model.
If the model is found but fails to load, check the backend. The model YAML backend must match the model format. GGUF models use llama-cpp; diffusion models use diffusers. Check installed backends with local-ai backends list, install the missing backend, and re-download a corrupt model file instead of tuning settings around a partial download.
If the process is killed or loading fails with memory pressure, use a smaller quantization, reduce context_size, enable low_vram: true where appropriate, or keep only one active backend with --max-active-backends=1. The idle watchdog can unload unused models after a timeout. Memory errors rarely improve by restarting the same oversized model and hoping.
If the GPU is not detected, verify the host first. For NVIDIA, run nvidia-smi and test GPU passthrough in Docker. Confirm you are using a CUDA image, not the CPU image. For AMD, check ROCm and the /dev/kfd and /dev/dri device passthrough. For Intel, use the Intel image and /dev/dri. The container cannot use a GPU the host does not expose.
If requests return 401, the server expects a key and the client sent none or the wrong one. Compare the client’s key variable with the server setting, and check whether a proxy dropped the authorization header. If requests return connection refused, check whether the container is running, whether port 8080 is already used by another service, and whether you are calling the host port you actually published.
Tips and tricks that save time
Prove the boring path first: CPU image, small model, web chat, one API call, then authentication. Each step isolates one failure. If you begin with a GPU image, a large model, user accounts, and a remote client in the same hour, every error looks like every other error.
Name models exactly as LocalAI lists them. Keep a short runbook with the model ID, backend, image tag, compose file location, backup location, and the test curl command. The next person should not need to reverse-engineer your first successful afternoon.
Limit active backends on modest hardware. One good model that stays loaded is usually more useful than three models fighting for memory. Use the watchdog when the server sits idle between jobs.
Watch disk before it watches you. Models, backends, caches, uploads, and generated files all grow. The FAQ’s 2–3 times model-size headroom is a starting rule, not a lifetime guarantee. Check free space before installing the next model.
Keep the paid API as a measured fallback during the trial. Route low-risk, repetitive work to LocalAI first. Compare answer quality, latency, and failure rate on your own prompts. A private endpoint is valuable only when the work it returns is good enough to use.
The real cost maths: LocalAI versus the OpenAI API
LocalAI costs $0 under the MIT licence. The model you run may have its own licence, and the hardware, electricity, storage, backup, and administrator time are yours. The honest comparison is therefore not “free versus paid” in the abstract. It is your token volume against the annual cost of the machine and care LocalAI needs.
Use a realistic internal workload: 25,000 requests a month. Each request averages 2,000 input tokens and 400 output tokens. That is 50 million input tokens and 10 million output tokens a month.
At OpenAI’s official GPT-4o mini prices, input costs 50 × $0.15 = $7.50. Output costs 10 × $0.60 = $6.00. The monthly API bill is $13.50, or $162 a year, before any cached-input saving. If LocalAI runs that workload on a machine you already own, the software saving is $162 a year before electricity and maintenance.

That number cuts both ways. If you must rent or buy hardware only for this workload and the annual hardware plus hosting cost is above $162, the hosted API is cheaper on cash alone. If the machine already exists, the workload is steady, and the local model passes your quality test, LocalAI can remove the token bill and keep prompts on your hardware. If token volume rises, the hosted bill rises with it; LocalAI’s cost rises mainly when hardware, power, or support needs rise.
Do not compare LocalAI with ChatGPT Plus as if they were the same product. ChatGPT Plus is $20 a month for the ChatGPT web app. LocalAI is an API server for apps and clients. The fair anchor for LocalAI is the API workload it actually replaces.
When not to self-host LocalAI
Do not self-host LocalAI when the work needs the best available model quality on every answer and your local model fails your own tests. A cheaper wrong answer is still wrong, and staff will route around it.
Do not self-host when nobody owns updates, backups, keys, and downtime. A server with authentication off, no backup, and a model nobody can name is not a private AI strategy. It is an incident waiting for a busy day.
Do not self-host for customer-facing work until you have tested load, latency, failure behaviour, and access control. LocalAI can serve a team, but your business still carries the service promise. If the server stops, your customers will not blame the licence.
Do not self-host when the token volume is tiny and the hosted API bill is lower than the time you will spend maintaining the server. Self-hosting earns its place through privacy, control, steady volume, or a workload that must stay on your hardware. It does not earn its place because the software price is $0.
Pros and cons
Pros: $0 under the MIT licence; OpenAI-compatible API on your own hardware; CPU route with optional GPU images; web interface plus API from one server; four-volume Compose setup preserves models, backends, settings, and data; API keys or full user authentication available.
Cons: authentication is off by default and must be fixed before exposure; model quality and speed depend on your hardware; you own updates, backups, storage, and downtime; legacy API keys grant full admin access; model licences differ from LocalAI’s MIT licence; a small token workload may be cheaper on a hosted API.
Our verdict
Install LocalAI if you need a private OpenAI-compatible endpoint and you can run a server responsibly. Start with Docker Compose, the CPU image, a small model, and one API test. Turn on authentication before anyone else can reach port 8080. Keep the hosted API for work the local model fails, and move only the workloads that pass your own quality and cost test.
FAQ
Is LocalAI really free for business use?
LocalAI is free under the MIT licence. That covers LocalAI itself. Check each model’s own licence before business use, because the model licence can differ from the server licence.
Does LocalAI need a GPU?
No. LocalAI runs on CPU, and a GPU makes it faster. Use the CPU image first unless your GPU host setup is already proven.
How do I point an OpenAI client at LocalAI?
Set the client’s base URL to http://localhost:8080/v1, or set OPENAI_BASE_URL=http://localhost:8080/v1 when the client reads that variable. Use a model name from /v1/models.
Why does LocalAI return “model not found”?
The requested model name does not match an installed model, or the model is not in the models path LocalAI is using. Check /v1/models, then check the models directory and backend.
Is LocalAI safe to expose on my network?
Not with default settings. LocalAI listens on all interfaces on port 8080 with authentication off. Set an API key or enable user authentication, register the intended admin first, and keep the server on a controlled network.
Strategic Pivot: price the whole stack before you switch
LocalAI can remove one API bill. It does not price the rest of your AI stack, and the rest is where small businesses quietly overspend. Before you cancel or renew any plan, put the tools, seats, token volumes, and monthly prices you actually use into our AI Cost Calculator and look at the yearly total.
Then decide with the number in front of you. Move the steady, private, good-enough workloads to LocalAI. Keep the hosted plan that earns its cost. Cancel the line that survives only because nobody added it up.
Sources
- LocalAI official Quickstart
- LocalAI official Containers guide
- LocalAI official Authentication and Authorization guide
- LocalAI official FAQ
- LocalAI official Troubleshooting guide
- OpenAI official GPT-4o mini model page
- OpenAI Help Center: What is ChatGPT Plus?
Price note — updated 1 December 2026: Prices in this post were checked on 1 December 2026. When you are reading this, the price may be lower or higher — always check the official pricing page before you buy.
Pros
- $0 under MIT
- OpenAI-compatible API on your own hardware
- CPU route with optional GPU images
- web interface plus API from one server
- four-volume Compose setup preserves models, backends, settings and data
- API keys or full user authentication available
Cons
- Authentication is off by default and must be fixed before exposure
- model quality and speed depend on your hardware
- you own updates, backups, storage and downtime
- legacy API keys grant full admin access
- model licences differ from LocalAI's MIT licence
- a small token workload may be cheaper on a hosted API
Install LocalAI if you need a private OpenAI-compatible endpoint and can run a server responsibly. Start with Docker Compose, the CPU image, a small model and one API test. Turn on authentication before anyone else can reach port 8080.
