OpenAI-compatible API: what it means and what differs

An OpenAI-compatible API is a service that accepts the same HTTP requests as OpenAI's API and answers in the same shape. You change a base URL and a key in your code, and your existing client keeps working. The match is partial, though. Each provider supports a subset, and the gaps decide whether a switch is easy.

This piece covers the common parts, the usual differences and a short test list. We read the OpenAI API reference and the docs of vLLM, Ollama, Groq and Together AI on 2 Dec 2026. These are examples, not a ranking, and docs change, so check the current pages.

What "compatible" means

Compatible means your code can talk to a different server by changing settings, not code. Three things carry over.

The base URL. OpenAI's examples call https://api.openai.com/v1/chat/completions. A compatible provider gives you its own base URL ending in /v1 or similar. Together documents https://api.together.ai/v1, Groq documents https://api.groq.com/openai/v1, and Ollama's local examples use http://localhost:11434/v1/.

The key header. OpenAI says to "provide API credentials with HTTP Bearer authentication", in the form Authorization: Bearer <key>. Official client libraries set this for you. Some servers do not check the key. Ollama says "the client requires an API key value, but Ollama ignores it."

The request and response shape. The endpoint is POST /chat/completions (reference). A request needs messages and model. The response holds a list called choices, and each choice has a message with role set to "assistant" and the text in content. With stream set to true, the reply arrives as server-sent events: lines that start with data:, each holding a chunk object, ending with data: [DONE].

vLLM lists chat completions (/v1/chat/completions) among the OpenAI APIs it supports, along with completions, Responses, embeddings, and audio transcription and translation. It says chat completions apply only to "text generation models with a chat template".

What is usually the same

If a provider supports chat completions, these tend to work as written: the endpoint path, messages as a list of role and content pairs, model as a string, and the choices[].message response. Streaming with data: lines is what OpenAI documents, so a client built for it expects that format.

What commonly differs

Do not assume anything below. Read each provider's page.

Model names. model is an ID that the provider defines. OpenAI's reference shows an OpenAI model ID. Another provider uses its own IDs. Ollama's page notes that tools which rely on default OpenAI model names, such as gpt-3.5-turbo, can be pointed at a local model by copying it to that name. Together goes the other way. Its page says OpenAI model strings like gpt-4o return a 404.

Supported parameters. Ollama says it "supports a subset of the OpenAI API." Groq says some fields "will result in a 400 error" if you send them: logprobs, logit_bias, top_logprobs and messages[].name. It also says n must equal 1, and that a temperature of 0 is converted to 1e-8. Together says logit_bias is not supported on most models, that seed is best-effort, and that service_tier, store, metadata and prediction are accepted but ignored. vLLM says its user parameter is ignored. So one server returns an error, another silently ignores the field.

Tool calling. Together lists function calling under chat completions. Ollama lists tools in its chat completions features. vLLM treats it as an option you turn on: its tool calling docs call --enable-auto-tool-choice mandatory for auto tool choice, and a --tool-call-parser flag selects a parser for the model. vLLM also says that with parallel_tool_calls set to false it returns zero or one tool call per request, and that more than one is not guaranteed when it is true.

Structured output. Together lists structured outputs under chat completions. Ollama lists JSON mode and accepts response_format. We did not confirm JSON-schema output for vLLM or Groq on the pages we read, so test it.

Streaming details. OpenAI documents the data: lines and the final data: [DONE]. We did not find the same detail on the other providers' pages. Test how your client handles the stream.

Other APIs. OpenAI recommends its Responses API for new projects. vLLM, Ollama, Groq and Together each list Responses support, and Ollama's page shows stateless Responses requests. Together says Assistants, Threads and Runs are not supported. If you use anything beyond chat completions, check it separately.

Rate limits and errors. OpenAI says to inspect response headers for rate limit details. The pages we read for the other providers did not describe their headers or error bodies in a way we could compare. Treat limits and error handling as provider-specific and test them.

A small example

The Python openai client takes a base URL and a key. Replace the placeholders with values from your provider's docs.

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://PROVIDER_HOST/v1",  # placeholder
    api_key=os.environ["PROVIDER_API_KEY"],
)

reply = client.chat.completions.create(
    model="PROVIDER_MODEL_ID",  # placeholder: use the provider's name
    messages=[{"role": "user", "content": "Say hello."}],
)
print(reply.choices[0].message.content)

Together's docs show the same two changes, an API key and a base URL, in this client.

Test a provider before you switch

Run these against your real prompts, not a demo.

  1. Plain request. Send one chat completion and check choices[0].message.content.
  2. Model name. Confirm the exact model ID the provider expects.
  3. Your parameters. Send every parameter your app sets. Note which return an error and which are ignored.
  4. Streaming. Run a streamed reply to the end and check how your client handles the last chunk.
  5. Tool calls. If you use tools, send a request that should trigger one and check the arguments parse.
  6. Structured output. If you rely on a JSON schema, check that the reply follows it.
  7. Errors and limits. Trigger a bad request and a rate limit if you can. Check what your retry code sees.
  8. Keep a fallback. Keep the old provider reachable by config until the tests pass. Our piece on LLM failover covers the routing side.

For the wider decision, see how to choose an inference provider and switching from OpenAI to open-weight models.

What we are building

We are building Starfield Fabric.

Related

Starfield Fabric · Switch from OpenAI to open-weight models · How to choose an inference provider · LLM failover: when your AI provider goes down