# OpenAI-Compatible API

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

**Field:** Artificial Intelligence  
**Category:** Running Locally  
**Also known as:** OpenAI-Compatible Endpoint, OpenAI-Compatible Server, OpenAI API Format

## Think of it like

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

## 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

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.

## 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.

## Why it matters

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

## Common mistake

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

## Three principles

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

## Related terms

- [Ollama](https://learn.benibix.com/term/ai/ollama)
- [LM Studio](https://learn.benibix.com/term/ai/lm-studio)
- [llama.cpp](https://learn.benibix.com/term/ai/llama-cpp)
- [Inference Engine](https://learn.benibix.com/term/ai/inference-engine)
- [Open WebUI](https://learn.benibix.com/term/ai/open-webui)
- [Application Programming Interface (API)](https://learn.benibix.com/term/development/api)
- [REST API](https://learn.benibix.com/term/development/rest-api)

## Told apart from

- [OpenAI API vs OpenAI-Compatible API](https://learn.benibix.com/compare/openai-api-vs-openai-compatible-api): People think any server that speaks the OpenAI format is OpenAI's own API. The OpenAI API is a service run by OpenAI, and it runs only its own models. A compatible API is any server that takes calls in the same shape. It might run a model on your laptop, or one from another firm. Your code stays the same, but the model behind it changes.

![Four layers of a local AI setup, top to bottom. A chat screen, such as Open WebUI or Jan. An OpenAI-compatible API on the same machine, at an address like localhost:11434/v1. A runtime that runs the model, such as Ollama, llama.cpp, LM Studio, Jan or MLX. And the weights file it loads, as GGUF or safetensors. Under it all sits your own hardware.](https://learn.benibix.com/diagrams/ai4-local-stack.svg)

---

Source: https://learn.benibix.com/term/ai/openai-compatible-api
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
