SU8 Codes
< Back to blog
Official article 7 min read

OpenAI-Compatible APIs Explained

What an OpenAI-compatible API is, how to connect with just a base_url, an API key and a model name, and where providers differ: base_url paths, feature subsets and model lists. As of November 15, 2026.

#openai#api#tutorial
OpenAI-Compatible APIs Explained

The short answer

  • "OpenAI-compatible" on a provider's docs page means: the provider implements the same request and response format as OpenAI's Chat Completions API. You keep your code and your tools, and point them at a different address (the base_url) with a different key.
  • To connect, you need three things: a base_url, an API key, and a model name from that provider's list.
  • Compatible does not mean identical: base_url paths differ between providers, feature coverage is usually a subset, and model names are each provider's own. All details below are from official sources as of November 15, 2026.

What the format defines

When you send a chat request, two fields carry almost everything:

  • model — the model name, taken from the provider's list.
  • messages — the conversation as a list, where each item has a role: user (your prompt), assistant (the model's earlier reply), system or developer (standing instructions at the start).

Everything else is optional, such as temperature to control randomness.

The response shape is fixed. The field definitions below come from the type files in openai-python, OpenAI's official SDK repository.

  • choices[0].message.content — where the model's reply text lives.
  • usage — token accounting (a token is the small unit models split text into): prompt_tokens, completion_tokens, total_tokens.
  • finish_reason — why generation stopped: stop for a natural stop, length when a token limit truncated the output, plus values for tool calls.

Streaming works over the same endpoint: set stream to true and the reply arrives in chunks, which is what the SDK's stream=True maps to.

Why so many providers speak this format

The ecosystem rewards it. Tools and SDKs are written against this format, so a new model provider can make existing tools work from the start by opening an endpoint that speaks it. DeepSeek states this directly in its docs: "The DeepSeek API uses an API format compatible with OpenAI/Anthropic. By modifying the configuration, you can use the OpenAI/Anthropic SDK or softwares compatible with the OpenAI/Anthropic API to access the DeepSeek API."

The format reaches beyond hosted APIs. Three different kinds of projects, all in their own official docs:

  • DeepSeek (hosted API): declares OpenAI/Anthropic format compatibility on its docs home page.
  • Ollama (runs open models on your machine): "Connect OpenAI clients to Ollama" (OpenAI compatibility docs) — your local server acts as an OpenAI endpoint.
  • vLLM (a serving layer for self-hosted models): lists an "OpenAI-compatible API server" among its core features.

OpenAI's own position explains why the format is safe to build on. In the official SDK's docs, the newer Responses API is called the primary API, while Chat Completions is labeled "The previous standard (supported indefinitely) for generating text." The compatibility ecosystem follows Chat Completions, and OpenAI has committed to keeping it.

How to connect: three things

The base_url (the service address, named base_url or baseURL in SDKs). It sits one level above the full endpoint: SDKs take the domain plus version path (for example https://xxx/v1), while raw curl calls need the full path including /chat/completions.

The API key, sent in the request header as Authorization: Bearer <your key>.

The model name, taken from that provider's own list rather than from memory.

A concrete example. SU8 Codes, a service that exposes many models behind one key, publishes an API examples page with a documented base_url of https://www.su8.codes/v1 (as of November 15, 2026). With a key from its console and a model from its list, a first request is a few lines:

from openai import OpenAI

client = OpenAI(
    api_key="<your key>",
    base_url="https://www.su8.codes/v1",
)
completion = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Hello"}],
)
print(completion.choices[0].message.content)

Or with curl, no SDK needed:

curl https://www.su8.codes/v1/chat/completions \
  -H "Authorization: Bearer <your key>" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-5.5", "messages": [{"role": "user", "content": "Hello"}]}'

(The address and model name above are taken from that docs page; the model list itself is the source of truth.)

Compatible does not mean identical

Three gaps show up in practice.

base_url paths are inconsistent. The official OpenAI SDK defaults to api.openai.com/v1 (set in the SDK source); DeepSeek's documented address has no /v1 at all (https://api.deepseek.com); a local Ollama server is http://localhost:11434/v1/, trailing slash included; the example above ends in /v1. Copy the address exactly as each provider's docs give it — do not assemble it yourself.

Feature coverage is a subset. Compatible endpoints usually land the common core first. Ollama's docs say so plainly ("Ollama supports a subset of the OpenAI API") and enumerate field by field — logprobs (per-token log probabilities) and tool_choice (forcing a specific tool) are on its not-supported list. Check the provider's feature list before you depend on a parameter.

Model names are per provider. The model field maps to each provider's own catalog. An official model name may be renamed or absent elsewhere, so pull names from the list, not from memory.

First-request checklist

Most failures are one of three small things:

  • base_url level — some tools want the base_url, others want the full path down to /chat/completions; follow the tool's docs.
  • the key — copied in full, no stray spaces, still valid.
  • the model name — exactly as it appears in the provider's list.

A minimal curl like the one above separates these causes in seconds, which beats digging through logs in a full project. To wire a working endpoint into an actual coding tool, the Codex CLI tutorial walks through a complete config.

FAQ

Is an OpenAI-compatible API the same thing as Chat Completions?

Essentially, yes. The compatibility ecosystem is anchored on the Chat Completions format. OpenAI's newer Responses API uses a different shape, and some providers implement it too — Ollama's docs, for example, include /v1/responses examples. Whichever surface a provider exposes, its docs are the reference.

Do I have to rewrite my code to switch providers?

Usually not. SDKs and tools parse the same format, so most of the time only the configuration changes (base_url and key). Model names do change, though: each provider's model value comes from its own catalog, so check the new list. DeepSeek's "By modifying the configuration" line is the mechanism in one sentence. If you rely on provider-specific parameters, re-check them against the new provider's feature list.

Is pricing the same as OpenAI's official API?

Pricing is set by each provider and has nothing to do with compatibility. The same model can carry very different street prices at different relays; we broke down how to read a quote in our article on reading API relay quotes.

Which model name should I use?

Whatever appears in the provider's list. Choosing which model is a separate question — Best LLM for Coding: Choose by Task sorts that by workload.