An API is described as OpenAI-compatible when it accepts the same HTTP shape as OpenAI's API. That usually means a chat completions endpoint, a models endpoint and an API key header. It does not mean every feature works, every field is accepted, or every response is identical.
The OpenAI Python SDK makes the swap look trivial because it lets you set a base URL through the client argument or the OPENAI_BASE_URL environment variable. That is genuinely useful for prototypes. For production, compatibility has to be tested endpoint by endpoint. This guide compares five common targets and the gaps their own documentation admits.
| Surface | Best for | Base URL pattern | Documented strengths | Documented gaps |
|---|---|---|---|---|
| OpenAI | Reference behaviour and newest features | https://api.openai.com/v1 | Full SDK surface | Not a compatibility target for cost or residency |
| Together AI | Open-model chat, vision, audio and images | https://api.together.ai/v1 | Chat, vision, tools, structured output, images, speech, transcription, Responses API | Embeddings only on dedicated endpoints; assistants, runs and OpenAI-shaped batches unsupported |
| Groq | Low-latency chat with a narrow model set | https://api.groq.com/openai/v1 | Chat completions, tools, streaming, Responses API | No logprobs, logit_bias or top_logprobs; N must be 1; messages[].name unsupported |
| Ollama | Local models behind the OpenAI SDK | http://localhost:11434/v1 | Chat, completions, models, embeddings, speech, transcription; non-stateful Responses | API key is ignored locally; stateful Responses fields unsupported |
| OpenRouter | Many upstream providers behind one key | https://openrouter.ai/api/v1 | Chat and Responses endpoints; provider routing and fallback | Behaviour and latency vary by upstream provider |
| vLLM | Self-hosted serving on your own GPUs | Your server URL plus /v1 | OpenAI-compatible server; also Anthropic Messages and gRPC | You operate capacity, upgrades and model serving |
Compatibility is a wire format, not a feature guarantee
The OpenAI SDK sends JSON to an endpoint and parses JSON back. An OpenAI-compatible server can accept that JSON and ignore fields it does not understand, reject them with a 400, or accept them with different behaviour. All three are possible, and only the first is safe.
Groq documents the second behaviour clearly. Its compatibility page says logprobs, logit_bias, top_logprobs and messages[].name are not supported and return a 400, and that N must equal 1. It also converts a temperature of 0 to 1e-8. Those are small differences that can break an evaluation harness or a retry policy.
Together documents the third behaviour at the endpoint level. Its OpenAI compatibility matrix marks chat, vision, tools, structured outputs, images, speech, transcription and the Responses API as supported, but embeddings only on dedicated endpoints. Assistants, threads and runs are not supported, and OpenAI-shaped fine-tuning and batch APIs are not either. The SDK call may exist; the backend behaviour does not.
- Test the exact endpoints you call, not just chat completions.
- Send every field you use in production, including optional ones.
- Compare error codes and retry behaviour, not only successful responses.
- Record the provider's compatibility page version with your integration notes.
The base URL swap in practice
A minimal Python swap looks like this: import the OpenAI client, set base_url to the provider's /v1 URL, and set api_key to the provider's key. The SDK's own documentation shows base_url as a client argument and OPENAI_BASE_URL as an environment variable, so the same pattern works in the Python SDK.
The first run usually works. The second run is where teams discover that the provider does not support a response format, a tool schema or an audio endpoint. Build a smoke test that covers chat, streaming, tools, structured output, embeddings and one audio call if you use it. Run it in CI against every provider you support.
Keep the base URL in configuration, not in code. A provider change should be a deployment setting, not a release. The same applies to the model name, which is not portable across providers even when the underlying model is the same.
Five failure modes to test before migration
The first is unsupported fields. A 400 on logprobs or top_logprobs is easy to spot. A silent ignore is worse, because your evaluation stops measuring what you think it measures.
The second is tool calling. Providers differ on parallel tool calls, argument streaming and the shape of the tool call ID. Test a multi-turn tool loop, not a single call.
The third is embeddings. Together's compatibility matrix is explicit that serverless embeddings are not available, only dedicated endpoints. A provider that supports chat does not automatically support embeddings, and dimensions may differ even when it does.
The fourth is stateful responses. Ollama supports the Responses API only in its non-stateful form, with no previous_response_id or conversation support. If your application relies on server-side state, you need to manage it yourself.
The fifth is usage accounting. Token counts, cached-token fields and finish reasons can differ. If you bill internally or enforce budgets, reconcile the provider's usage object against your own counter for a week before trusting it.
Compatibility does not cover billing or limits
Two providers can accept the same chat request and return different usage objects. Input tokens may include cached tokens or exclude them. Output tokens may include reasoning tokens or report them separately. If you enforce budgets from the provider's usage field, reconcile it against your own count for a week before trusting it.
Rate limits are also outside the compatibility claim. A provider may accept the OpenAI request shape but apply a requests-per-minute, tokens-per-minute or spend limit that the SDK does not understand. The SDK will retry some 429 responses and surface others, so the application needs its own backoff and a clear error message.
Model names are the last hidden dependency. The same open model can have different IDs, context limits and pricing at two providers. Keep the model name in configuration with the provider, and pin a version where the provider offers one. A silent model upgrade can change quality and cost without a code change.
- Compare usage objects for the same request across providers.
- Test 429 behaviour and confirm the SDK's retry policy.
- Pin model versions and record the provider's alias policy.
- Log the provider, model and base URL with every request.
When a competitor wins
Together wins when you want one OpenAI-shaped surface across chat, images, speech and transcription, and you can live without serverless embeddings or OpenAI-shaped assistants. Its US endpoint costs 1.25 times standard serverless rates on select models, which is a real option for residency-sensitive work.
Groq wins when latency dominates and your feature set is narrow. Its gaps are documented and predictable, which is better than undocumented surprises. Ollama wins for local development and air-gapped prototypes, where ignoring the API key is a feature rather than a bug. OpenRouter wins when you want one key across many upstreams and accept variable behaviour. vLLM wins when you own the GPUs and want an OpenAI-compatible server you control.
A native SDK wins when the provider's unique features matter. If you need a provider's batch API, fine-tuning shape or agent runtime, an OpenAI-compatible shim is the wrong abstraction. Use the native client and accept the integration cost.
Plugsky is the option when the SDK swap is also a procurement or boundary change. It exposes an OpenAI-compatible API with flat plans at $20, $60 and $120, and a deployment path from public API to private VPC, on-premises or air-gapped by contract. Test the same endpoint matrix before assuming parity.
Verdict
Use the OpenAI SDK as a portability layer for the common surface: chat, streaming, tools and structured output. Test embeddings, audio and stateful responses separately, because those are where compatibility claims diverge.
If your application can run on chat completions plus tools, any of these providers can work. If it depends on assistants, batches or provider-specific fine-tuning, choose the native SDK and budget for the migration.
Frequently asked questions
What does OpenAI SDK compatible mean?
The provider accepts OpenAI's HTTP request shape and returns a compatible response for some endpoints. It does not guarantee every endpoint, field or behaviour is supported.
Can I just change the base URL?
For a basic chat completion, often yes. For tools, embeddings, audio, structured output or stateful responses, test each endpoint. Some providers reject unsupported fields with a 400, and others ignore them.
Does Together AI support OpenAI embeddings?
Only on dedicated endpoints, according to its compatibility matrix. Serverless embedding models are not offered.
Does Ollama need an API key?
The local server ignores the key value but the OpenAI client requires one, so teams set a placeholder. Ollama Cloud uses a real key.
Is vLLM a drop-in replacement for OpenAI?
It provides an OpenAI-compatible server, but you own the GPU capacity, model serving and upgrades. Compatibility of the API does not remove the operational work.
Related
Sources
- OpenAI Python SDK README · 23 Nov 2026
- Together AI OpenAI compatibility · 23 Nov 2026
- Groq OpenAI compatibility · 23 Nov 2026
- Ollama OpenAI compatibility · 23 Nov 2026
- OpenRouter quickstart · 23 Nov 2026
- vLLM README · 23 Nov 2026