Searching for an OpenAI API alternative usually means one of two things. Either the provider implements the same request format as OpenAI, in which case you can often keep your client code and change the base_url, the API key, and the model name. Or the provider exposes a different API, in which case you are rewriting the integration, not just the configuration.
This article covers the first group. Every service below was checked against its official documentation on November 15, 2026. The list is grouped by type, not ranked. If you want the format itself explained first, see OpenAI-Compatible APIs Explained.
Two terms first. base_url is the service address you give the SDK; the SDK appends the endpoint path to it. An OpenAI-compatible endpoint is a service entry point that follows the Chat Completions request and response shape. Compatibility is about the format. It does not promise that every feature behaves the same way.
Short answer
- A real drop-in candidate documents an OpenAI-compatible endpoint and shows an OpenAI SDK example. The configuration usually changes in three places:
base_url, API key, model name. - Compatibility is usually a subset, not full parity. Check Responses API support, tools, vision, structured outputs,
logprobs, streaming usage, and error semantics before you migrate. - The
base_urlstring must be copied exactly. Some providers include/v1, some do not, some end with a slash, and some include a workspace ID or deployment name.
What changes when you switch base_url
The official OpenAI Python SDK accepts a base_url argument when you create the client, and it also reads the OPENAI_BASE_URL environment variable. In the standard API-key setup, if neither is set, it defaults to https://api.openai.com/v1 (README, _client_auth.py, checked November 15, 2026).
When you point that client at a compatible service, three things usually change:
base_url— the address from the provider's docs.- API key — the key issued by that provider.
model— a name from that provider's model list, not the OpenAI model name you used before.
The SDK calls, the messages array, and the choices structure in a Chat Completions response often stay the same. The word "often" matters. Compatible endpoints tend to implement the common core first. If your code relies on the Responses API, tool calling, vision input, structured outputs, or usage data in a streaming response, check the provider's support table line by line.
OpenAI API alternatives with documented compatible endpoints
The table is a quick scan. The sections below add the details that affect migration. This is not an exhaustive list; providers add and change compatibility pages, so use the same checks on any service you are considering.
| Service | Type | base_url in the official docs | Notes |
|---|---|---|---|
| OpenRouter | Aggregator | https://openrouter.ai/api/v1 | Docs describe the OpenAI SDK as a drop-in replacement; supports Responses and Chat Completions |
| SU8 Codes | Aggregator | https://www.su8.codes/v1 | Docs include OpenAI SDK examples for Responses and Chat Completions; checked against the criteria below |
| DeepSeek | Model vendor | https://api.deepseek.com | Declares OpenAI/Anthropic format compatibility; no /v1 in the URL |
| Kimi (Moonshot) | Model vendor | https://api.moonshot.ai/v1 | Docs mark Chat Completions and Responses as OpenAI-compatible |
| Z.AI (GLM) | Model vendor | https://api.z.ai/api/paas/v4/ | Docs list an OpenAI SDK compatibility option; some scenarios still differ |
| Alibaba Cloud Model Studio (Qwen) | Model vendor | https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1 | URL includes a workspace ID and a region |
| Fireworks | Inference platform | https://api.fireworks.ai/inference/v1 | Docs list differences in max_tokens and streaming usage |
| Ollama | Local runtime | http://localhost:11434/v1/ | Supports a subset of the OpenAI API |
| vLLM | Self-hosted | http://localhost:8000/v1 (docs example) | Feature list includes an OpenAI-compatible API server |
Aggregators
OpenRouter puts the claim directly in its Quickstart: the OpenAI SDK can be pointed at OpenRouter as a drop-in replacement. The documented base_url is https://openrouter.ai/api/v1, and the API supports two request shapes, the Responses API and Chat Completions. The schema is not field-for-field identical. OpenRouter's API overview says its request and response schemas are "very similar" to OpenAI's, and it normalizes each model's finish_reason to tool_calls, stop, length, content_filter, or error. The raw value is kept in native_finish_reason. If your code branches on the original string, that branch needs attention.
SU8 Codes documents OpenAI Python SDK examples for both Responses and Chat Completions, with https://www.su8.codes/v1 as the base_url and a model name copied from its model list. It is a service that exposes multiple models behind one key. The section "One OpenAI API alternative checked against the criteria" below runs it through the same checklist used for the other providers.
Model vendors
DeepSeek states in its docs that the API uses a format compatible with OpenAI and Anthropic, and that changing the configuration lets you use the OpenAI or Anthropic SDK. The OpenAI-format base_url is https://api.deepseek.com, with no /v1. The same page also documents https://api.deepseek.com/anthropic for the Anthropic format. The example model name is deepseek-flash.
Kimi (Moonshot) marks Chat Completions and Responses as OpenAI-compatible formats, with support for the OpenAI Python and Node.js SDKs; its Messages API follows the Anthropic format instead. The international base_url is https://api.moonshot.ai/v1. The China site documents https://api.moonshot.cn/v1, so use the host that matches the platform where you registered.
Z.AI (GLM) lists "OpenAI SDK Compatibility" as a way to migrate from OpenAI. The documented base_url is https://api.z.ai/api/paas/v4/, and the page shows an OpenAI Python SDK example. The Chinese-language Zhipu docs are more explicit about the caveat: some scenarios still differ between the two APIs, so check the parameters you actually use.
Alibaba Cloud Model Studio (Qwen) says you can migrate existing OpenAI code by changing only the API key, base URL, and model name. The URL is regional and includes your workspace ID. The Singapore example in the English docs is https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1; other regions use different hosts. Copy the host for the region where your workspace and key live.
Inference platform
Fireworks documents OpenAI Python and JavaScript SDK support by pointing base_url at https://api.fireworks.ai/inference/v1. Its compatibility page also lists behavior differences. One example: if max_tokens plus the prompt exceeds the model's context window, Fireworks adjusts max_tokens down by default, while OpenAI returns an invalid request error. The context_length_exceeded_behavior parameter can switch Fireworks back to an error. For streaming responses, Fireworks returns usage in the last chunk; parsing code that assumes usage never appears in a stream needs a change.
Local and self-hosted
Ollama opens its compatibility page with "Ollama supports a subset of the OpenAI API." The local example uses base_url = 'http://localhost:11434/v1/', trailing slash included, and an API key that is required but ignored. In the current docs, Chat completions, streaming, JSON mode, vision, and tools are checked as supported; Logprobs is not. For /v1/chat/completions, the fields tool_choice, logit_bias, user, and n are not checked. The Responses API supports a stateless subset; previous_response_id and conversation are not supported.
vLLM lists an OpenAI-compatible API server in its feature set, for teams that deploy their own models. The server docs use base_url = "http://localhost:8000/v1" in the OpenAI Python client example. The user parameter is ignored, and vLLM-specific parameters such as top_k go through extra_body. Replace the host and port with your deployment.
How to tell if a provider is really drop-in
Open the provider's API or compatibility page and check these items. A mismatch on any one of them can mean code changes.
- An explicit compatibility statement and an OpenAI SDK example. "Supports the OpenAI format" in a blog post is weaker than a docs page that shows
from openai import OpenAIwith abase_url. Every service in this article has that kind of example in its official docs. - The exact
base_urlpath and ending. Some include/v1; some do not; some end with a slash. DeepSeek useshttps://api.deepseek.com, Ollama useshttp://localhost:11434/v1/, OpenRouter useshttps://openrouter.ai/api/v1, and Z.AI useshttps://api.z.ai/api/paas/v4/. Copy the string; do not assemble it. - Authentication. Most services accept
Authorization: Bearer <key>. Some read extra headers; OpenRouter, for example, documents optionalHTTP-RefererandX-OpenRouter-Titleheaders for attribution. If authentication changes, client initialization changes. - Model names. Take them from the provider's list. Reusing OpenAI model names is a migration mistake to check for. Alibaba's Qwen names, Kimi's model names, and Z.AI's GLM names all come from their own catalogs.
- Feature coverage. First decide whether you need Chat Completions or the Responses API. Then check tools, vision, JSON mode, structured outputs,
logprobs, and usage in streaming responses. Ollama publishes an explicit not-supported list; Fireworks documentsmax_tokensand streaming usage differences; OpenRouter documentsfinish_reasonnormalization. If the docs do not mention a feature, do not assume it works. - Error and rate-limit semantics. A 400, 401, or 429 may have different triggers and response bodies across providers. Do not move OpenAI error-code branches over unchanged; adjust retries to the new provider's docs.
- Data location and regions. Where requests are processed, where data is stored, and whether keys are region-bound are provider-specific. Alibaba's regional URLs are one example; read the docs for the service you pick.
- A minimal request. Send a request with only
modelandmessagesbefore migrating business code. That separates address, key, and model-name problems in one step.
What to check in your code before switching
Check configuration before blaming the SDK. Work through this list before sending production traffic.
- Search for
api.openai.com. Besides the SDK default, the address may be hardcoded in config files, environment variables, CI scripts, or a Dockerfile. - Search for
base_urlandOPENAI_BASE_URL. Make sure a second configuration layer does not set the old address back. - Search for model names. They may live in config, prompt templates, evaluation scripts, and log labels. Replace every occurrence with a name from the new provider's list.
- Search for OpenAI-specific parameters.
logprobs,tool_choice,logit_bias,user, andreasoning_effortare not universally supported; Ollama's current docs list several of them as unsupported. - Search for response fields you depend on.
usage,finish_reason,system_fingerprint, andlogprobsare common examples. A missing or normalized field can break parsing. OpenRouter'sfinish_reasonnormalization is a concrete case. - Check streaming parsers. Chunk fields, the location of usage, and the end marker can differ. Fireworks documents usage in the final chunk; a parser that assumes no usage in a stream will need work.
- Check token accounting. Providers may count tokens with their own tokenizer. Do not assume usage numbers are directly comparable with OpenAI's.
- Check error handling and retries. Timeouts, rate limits, and context-length errors may be reported differently. Adjust retry counts and backoff to the new provider.
- Run a fixed prompt set. Pick prompts that cover your main workloads, compare outputs, tool calls, streaming behavior, and usage numbers, then shift a small share of traffic first. Keep the old configuration so you can roll back.
Common pitfalls
The base_url has the wrong /v1 level
DeepSeek uses https://api.deepseek.com with no /v1. Ollama uses http://localhost:11434/v1/, with both /v1 and a trailing slash. OpenRouter uses https://openrouter.ai/api/v1, and Z.AI uses https://api.z.ai/api/paas/v4/. These are not style choices; they are the strings in each provider's docs. Copy them exactly.
The model name is still the OpenAI one
OpenAI model names do not necessarily exist elsewhere. Treat the model name as a configuration value, not a constant. Check the provider's list first rather than assuming the address or key is wrong.
"Compatible" is read as "feature-identical"
Ollama says it supports a subset of the OpenAI API, and its current docs leave Logprobs, tool_choice, logit_bias, user, and n unchecked. Fireworks handles max_tokens differently when the context is exceeded. OpenRouter normalizes finish_reason. Compatibility covers the format, not every feature.
Every provider is assumed to support the Responses API
OpenRouter and Kimi document Responses examples. Ollama supports a stateless Responses subset and not previous_response_id or conversation. Other providers may only offer Chat Completions. Confirm which API surface you are calling.
finish_reason is not the raw value
OpenRouter normalizes finish_reason to tool_calls, stop, length, content_filter, or error and exposes the raw value as native_finish_reason. Logic that branches on OpenAI's original string needs to change.
Streaming usage lives somewhere else
Fireworks returns usage in the last chunk of a streaming response. Chunk structure and end markers can also differ between providers. Do not treat "usage only appears in non-streaming responses" as a universal rule.
The workspace ID or region is wrong
Alibaba Cloud Model Studio puts a workspace ID and a region in the base_url. The docs list different hosts for different regions. Copy the full host for the region where your workspace lives rather than swapping only the domain.
OpenAI error codes are reused as-is
A 400, 401, or 429 may mean something different at another provider. Retry logic written around OpenAI error codes can classify a retryable error as permanent, or the reverse.
Required or optional headers are missed
OpenRouter documents optional HTTP-Referer and X-OpenRouter-Title headers for attribution. Other providers may have their own required headers. Read the request example in the docs instead of copying only the base_url and key.
One OpenAI API alternative checked against the criteria
The same checklist can be applied to SU8 Codes. The table uses SU8's official docs, checked November 15, 2026; items with a public page link to it, and items the public docs do not provide are marked as such. It is one option, not a recommendation for every project.
| Criterion | SU8 status | Source |
|---|---|---|
| Official docs, API coverage, and base_url | The API examples give https://www.su8.codes/v1 and show OpenAI Python SDK usage for both Chat Completions and Responses | API examples |
| Three changes | The official examples change only base_url, key, and model name; model names come from the model list | API examples, Models and usage |
| Usage details | The public docs say the console Usage details break each call into new input, cache read, cache write, and output | Models and usage |
| Multiple models | One key can call multiple models; to switch models, change the model name in the request; base_url and key stay the same | Models and usage, API examples |
| Public status page | The public docs do not provide an availability or status page; confirm before committing if your project requires one or a hard SLA | Public docs do not provide it |
SU8's model names and usage details are on its Models and usage page.
When it is not the right fit: if you need a specific model vendor's native features, going directly to that vendor is simpler; if you need fully offline inference, use Ollama or vLLM; if you require a public status page or a formal SLA, confirm that before choosing. SU8 is positioned as one key for multiple models, so whether it fits depends on the criteria and boundary above.
FAQ
Is changing the base_url enough for an OpenAI API alternative?
Usually you also change the API key and the model name. Feature coverage is a separate question: Responses API, tools, vision, and streaming usage need to be checked against the provider's docs. A provider that documents OpenAI compatibility is a candidate, not a guarantee of identical behavior.
Do you need to rewrite your OpenAI SDK code after switching?
Most of the time, no. The SDK calls stay the same; configuration and model names change. Code that uses OpenAI-specific parameters or depends on a particular response field may need edits. A checklist is cheaper than a rewrite.
Which OpenAI API alternative should you choose?
Start with the category. For multiple models behind one endpoint, look at OpenRouter. For a specific model vendor, look at DeepSeek, Kimi, Z.AI, or Alibaba Cloud Model Studio. For hosted inference, look at Fireworks. For local or self-hosted, look at Ollama or vLLM. Then run the checklist above; do not choose on a single "OpenAI-compatible" line.
Do all compatible providers support the Responses API?
No. OpenRouter and Kimi document Responses examples; Ollama supports a stateless subset. Other providers may only offer Chat Completions. Check the API list before you design around Responses.
What should you check first when the new base_url returns an error?
Check three things: whether the base_url was copied exactly (including /v1 and any trailing slash), whether the key is valid, and whether the model name appears in the provider's list. A minimal request with only model and messages separates address, authentication, and model-name problems faster than reading logs from a full application.
How do you confirm quality did not regress after switching?
Use a fixed prompt set that covers your main tasks. Compare outputs, tool calls, streaming behavior, and usage numbers, then move a small share of traffic and keep a rollback configuration. One or two sample prompts are not enough for a full switch.
Sources
- OpenAI official Python SDK README: https://github.com/openai/openai-python/blob/main/README.md
- OpenAI official SDK default base_url source: https://github.com/openai/openai-python/blob/main/src/openai/lib/_client_auth.py
- DeepSeek API docs: https://api-docs.deepseek.com/
- OpenRouter Quickstart: https://openrouter.ai/docs/quickstart
- OpenRouter API overview: https://openrouter.ai/docs/api-reference/overview
- Fireworks OpenAI compatibility: https://docs.fireworks.ai/tools-sdks/openai-compatibility
- Ollama OpenAI compatibility: https://docs.ollama.com/api/openai-compatibility
- vLLM documentation: https://docs.vllm.ai/en/latest/
- vLLM OpenAI-compatible server: https://docs.vllm.ai/en/latest/serving/online_serving/openai_compatible_server/
- Alibaba Cloud Model Studio OpenAI compatible chat: https://www.alibabacloud.com/help/en/model-studio/compatibility-of-openai-with-dashscope
- Kimi API quickstart: https://platform.moonshot.ai/docs/guide/start-using-kimi-api
- Kimi API quickstart (China site): https://platform.moonshot.cn/docs/guide/start-using-kimi-api
- Z.AI quickstart: https://docs.z.ai/guides/overview/quick-start
- Zhipu AI OpenAI compatibility (Chinese docs): https://docs.bigmodel.cn/cn/guide/develop/openai/introduction