2kw.ai
Sign inBook a 15-min demo
Glossary · OpenAI-compatible API

What is an OpenAI-compatible API?

An OpenAI-compatible API is a service that accepts requests in the format OpenAI's API defines — most often POST /v1/chat/completions with a messages array — and returns responses in the same shape. Code already written against an OpenAI SDK can call it by changing two values: the base URL and the API key.

Why the convention exists

OpenAI published a request format, a large number of applications were written against it, and the ecosystem of SDKs, frameworks and tools grew up around that shape. Any service that wanted those applications as customers had a choice: persuade every one of them to rewrite an integration, or accept the format they already send. Most chose the second. That is the whole mechanism — it is adoption, not standardisation.

The practical consequence is that the request shape has become the interchange format for the category. It is why switching model providers can be a configuration change, and why a gateway can put five providers behind one endpoint without asking your application to know which one answered.

What it guarantees, and what it does not

Guaranteed in practice: the core call
A chat completion with a messages array, a model string, temperature and max tokens, with or without streaming. This is the part every compatible implementation supports, because it is the part every application uses.
Usually works, worth testing: tools and structured output
Function and tool calling, and JSON or schema-constrained output, are widely supported and diverge in the details — how strictly a schema is enforced, how parallel tool calls are represented. Test these against your own code rather than assuming.
Not guaranteed: provider-specific parameters
Extended thinking budgets, prompt-cache control, safety settings, logprobs and similar features have no universal equivalent. A compatible endpoint may ignore them silently, approximate them, or reject the request.
Says nothing at all: everything operational
Rate limits, latency, uptime, retention, where the request is processed and under whose terms. Compatibility is a statement about message format. Every operational and compliance question has to be asked separately.

The two-line migration, and its honest caveat

Pointing an existing OpenAI client at a compatible endpoint means changing the base URL and the key. In most codebases that really is all, and it is reasonable to plan for it.

The caveat is that “most” is doing work in that sentence. The divergences cluster in streaming, tool calling and structured output, and they surface as subtly wrong behaviour rather than as errors — a tool call that arrives in a slightly different shape, a schema that is suggested rather than enforced. Run your own test suite against the new endpoint before you route production traffic to it. Any vendor telling you that step is unnecessary, including us, is overselling.

Common questions

Does OpenAI-compatible mean the service uses OpenAI models?

No, and this is the most common misreading. Compatibility describes the request and response format, not the model behind it. An OpenAI-compatible endpoint may route to Anthropic, Google, Mistral, or a model running on your own hardware. The wire format is what is shared; the intelligence answering is a separate question.

What actually has to change in my code?

In the typical case, two values: the base URL your client points at, and the API key it sends. Everything else — the messages array, the streaming flag, the tool definitions, the response parsing — stays as written. That is the whole point of the compatibility claim, and it is why migration between compatible services is usually a configuration change rather than a project.

What does OpenAI compatibility not guarantee?

It does not guarantee that every parameter survives. Provider-specific features — extended thinking budgets, cache control headers, safety settings, logprobs, specific tool-calling dialects — have no universal equivalent, so a compatible endpoint may ignore them, approximate them, or reject them. It also says nothing about rate limits, latency, retention, or where the request is processed.

Is the OpenAI API a standard?

Not a formal one. It is a de facto convention: enough services adopted OpenAI's request shape that it became the interchange format for the category, in the way S3's API became the convention for object storage. There is no standards body and no conformance suite, which is why compatibility is a claim each vendor makes rather than a certification anyone holds.

How do I verify a service is really compatible with my code?

Point your existing client at it and run your own test suite — that is both the fastest check and the only one that covers the parameters you actually send. Pay particular attention to streaming, tool or function calling, and structured output, because those are where compatible implementations most often diverge.

More from the platform
What is an LLM gateway? The layer that puts many providers behind one compatible endpoint.Best LLM gateways Nine gateways compared, including which are OpenAI-compatible and which are not.The 2kw.ai gateway One OpenAI-compatible endpoint for every major provider, with BYOK and EU data residency.Document extraction Schema-driven structured data extraction from 17 document formats.

Keep your OpenAI code. Change the base URL.

Start 7-day free trialBook a 15-min demo