Skip to content
BENIBIX Learn

OpenAI-Compatible API

AI💻 Running LocallyLocal Runtimes

Also known as OpenAI-Compatible Endpoint, OpenAI-Compatible Server, OpenAI API Format

A server that takes the same requests as OpenAI's API. Apps can switch to it.

Think of it like

It is like a plug that fits every socket in the house. Any lamp works with it.

Example

Jack's app calls the OpenAI API. He points it at http://localhost:11434/v1 instead. The same code now talks to a model in Ollama on his laptop.

Why it matters

You can try a local model in an app you already have, with no new code.

Definition

An OpenAI-compatible API is a server that takes requests in the same shape as OpenAI's API. Many local tools have one, such as Ollama, LM Studio, Jan and llama.cpp. An app made for OpenAI can talk to them. You change only the web address. The model behind it can then be one on your own machine. This shape became the common one, so one app can switch between many models.

Example code

bash
curl http://localhost:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "llama3.2", "messages": [{"role": "user", "content": "Hi"}]}'
This is the request shape OpenAI uses. Here it goes to Ollama on the same machine.
This API is the middle layer. Any chat app above can talk to any runtime below.

Common mistake

Expecting every feature to match. Tools copy the main calls. Some options are missing or work in a slightly new way.

Key takeaways

  1. 1
    Same shape. The requests look the same.
  2. 2
    Change the address. Point the app somewhere else.
  3. 3
    Not every feature. Mostly the main calls.

Compare