LocalAI: Open Source alternative to OpenAI API in 2026
LocalAI exposes an API 100% compatible with OpenAI's (chat, images, embeddings, audio) but running open source models on your own infrastructure, with no external API keys.
βΉοΈ The base image itself is small, but the models you download (GGUF/GGML) can add tens of GB on top β not included in this estimate. Runs on CPU; auto-detects and uses NVIDIA/AMD/Intel GPUs when available.
Audit Snapshot
View notes βLicense β Matches GitHub
GitHub β Active
Latest release β v4.11.0 Β· 11 days ago
Docker Compose β Partial
Production β Not production-tested by AltFreeStack
LocalAI vs. OpenAI API
Pros
- Near-direct migration from code already using the OpenAI API
Things to consider
- Needs decent hardware (ideally a GPU) for large models
Quick Docker installation guide
Copy this docker-compose.yml, adjust the example passwords and run docker compose up -d on your server. See the full step-by-step guide β
π‘ Official SaaS or self-hosted with AltFreeStack?
- On the official cloud: a recurring monthly fee and usage limits on OpenAI API.
- On your own VPS: 100% free software on your own server, with no artificial row, project or user limits.
version: "3.9"
services:
localai:
image: localai/localai:v3.12.1
restart: unless-stopped
ports:
- "8080:8080"
volumes:
- localai_models:/models
volumes:
localai_models:
π Deploy in 1 command
Recommended for beginnersCopy this single command and paste it into your freshly created VPS's console (Vultr, DigitalOcean...). It downloads the script, prints it to your screen so you can see exactly what it's about to do (never a blind direct pipe), and only then installs Docker if needed, writes the files with secrets already generated, and starts everything β no nano, no pasting code blocks.
curl -sSL ".../api/deploy?stack=localai" -o deploy.sh && cat deploy.sh && bash deploy.shThis docker-compose corresponds to an actively maintained project β last commit today.
This docker-compose not working for you? Report it on GitHub βTechnical profile
- License
- MIT
- Category
- Artificial Intelligence
- Replaces
- OpenAI API
- Tech stack
- GoC++
Under the hood
Database
None / File-based
Language
Go
Platforms
Web
Key features
- API compatible with the OpenAI SDK
- Chat, images, embeddings and audio
- Runs GGUF, GGML and more model formats
Preview

Public image provided by LocalAI on its own website.
πΎ Backups in 3 steps (Day 2)
As long as the ./data folder (the "volume" mapped into the container) exists on your server, your data survives any restart or container update β that's the only thing you need to back up.
1. Create a compressed backup on the server
tar -czvf backup-$(date +%F).tar.gz ./data2. Download it to your computer
From your computer's terminal (not your server's):
scp root@YOUR_IP:~/app/backup-*.tar.gz ./3. Restore in case of emergency
tar -xzvf backup-file.tar.gzπ Connect your domain with free SSL
Step 1 β Set up the DNS
In your domain registrar's dashboard (Cloudflare, Namecheap, GoDaddy...), create a record:
- Type
- A
- Name/Host
- @ (root domain) or a subdomain, e.g. app
- Content/Value
- Your server's public IP
Wait 5 to 15 minutes for the record to propagate across the internet.
Step 2 β Automatic reverse proxy with Caddy
One single file, no Nginx config or manual certificates β Caddy issues and renews Let's Encrypt HTTPS on its own.
Create a file called Caddyfile:
yourdomain.com {
reverse_proxy localhost:8080
}Start Caddy with this command (pulls the image and runs it in the background):
docker run -d -p 80:80 -p 443:443 --name caddy --restart always -v $PWD/Caddyfile:/etc/caddy/Caddyfile -v caddy_data:/data caddy