What is LocalAI?
LocalAI is a free, open-source alternative to the OpenAI API. It is a drop-in replacement that runs locally on CPU or GPU with no API keys required. It supports multiple model formats and is compatible with OpenAI's full API spec.
What It Replaces
POST /v1/chat/completions— LLM chat (GPT-4 equivalent)POST /v1/completions— text completionPOST /v1/embeddings— generate embeddingsPOST /v1/images/generations— image generation (Stable Diffusion)POST /v1/audio/transcriptions— speech to text (Whisper)POST /v1/audio/speech— text to speech
Quick Start
docker run -p 8080:8080 localai/localai:latest-aio-cpu
Then call:
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4", "messages": [{"role": "user", "content": "Hello"}]}'
When to Use LocalAI vs. Ollama
- Ollama — best for running individual LLM models locally with a clean CLI.
- LocalAI — best when you need to self-host the full OpenAI API surface (including embeddings, image gen, TTS) and want your existing OpenAI-built apps to work without code changes.