How to run an OpenAI-compatible API on your server
Updated 11/29/2026
Many apps and libraries are written for the OpenAI API. You can run a local API with the same structure, so your apps use your models without major changes.
Ollama exposes a compatible API
Ollama already offers an OpenAI-compatible endpoint:
curl http://localhost:11434/v1/chat/completions -d '{
"model": "llama3.2",
"messages": [{"role": "user", "content": "Hello"}]
}'
Configure the app
In your app, you only change the API base address and the key:
OPENAI_API_BASE=http://localhost:11434/v1
OPENAI_API_KEY=ollama
Code that used OpenAI now works with your local model.
Alternatives
For more features (images, embeddings, multiple models), projects like LocalAI offer a more complete OpenAI-compatible API, also running on your server.
Why it is worth it
- Fixed cost instead of per-token billing.
- Privacy: data does not leave the server.
- No externally imposed rate limits.
For large models and speed, see the GPU plans.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
An AI assistant over your company documents with AnythingLLM
Ask your documents questions and get answers with sources: the model, workspaces, documents and your team.
Updated 11/29/2026AI & self-hostingResearch across sources with Open Notebook, the NotebookLM alternative
Gather PDFs, web pages and videos in a notebook, then ask, summarize and generate podcasts with the model you choose.
Updated 11/29/2026AI & self-hostingHow to extract web data without code, using Maxun
Build robots that collect data from websites by clicking, without writing a line of code.
Updated 11/29/2026