---
title: "What is an OpenAI-compatible API? How it works | BroadRouter"
description: "An OpenAI-compatible API accepts the same requests as OpenAI, so existing SDKs work by changing the base URL, key and model. What matches, what differs, and why."
url: https://broadrouter.com/glossary/openai-compatible-api/
lang: en
updated: 2026-11-15
publisher: BroadRouter (a BroadNet site); API by BroadNet Inference, https://inference.broadnet.ai
---

# OpenAI-compatible API

Updated 2026-11-15

An OpenAI-compatible API is an HTTP API that accepts the same request and response formats as the OpenAI API, such as POST /v1/chat/completions, so OpenAI SDKs and tools can use it by changing only the base URL, the API key and the model name.

Also called: OpenAI API compatible, OpenAI-style API, OpenAI drop-in replacement

OpenAI’s API format became the common language of LLM tooling. Many providers now accept it, so one client library can talk to many backends.

## How it works

A compatible API copies the parts of the OpenAI API that clients depend on:

-   the same paths, such as `/v1/chat/completions` and `/v1/audio/transcriptions`;
-   the same JSON shapes: a `messages` array in, `choices[0].message.content` out, and a `usage` block with token counts;
-   an [API key](https://broadrouter.com/glossary/api-key/) sent as `Authorization: Bearer <key>`;
-   [streaming](https://broadrouter.com/glossary/streaming/) as server-sent events when `stream` is true.

Switching is a configuration change. With the official Python SDK:

```python
from openai import OpenAI
import os

client = OpenAI(base_url="https://inference.broadnet.ai/v1", api_key=os.environ["BROADNET_API_KEY"])
reply = client.chat.completions.create(
    model="broadnet/gemma-4-26b-a4b",
    messages=[{"role": "user", "content": "Say hello in Arabic."}],
)
print(reply.choices[0].message.content)
```

Only three values changed from an OpenAI example: the [base URL](https://broadrouter.com/glossary/base-url/), the key and the model ID.

## Why it matters

Compatibility lowers switching cost. SDKs, agent frameworks, IDE plugins and [routers](https://broadrouter.com/glossary/llm-router/) that speak the OpenAI format work without new code. You can test a second provider in minutes and keep the option to move.

But compatible is not identical. Anthropic’s own compatibility layer, for example, ignores `strict` on tools and leaves `prompt_tokens_details` empty. Typical gaps are:

-   parameters that are ignored or rejected;
-   how [reasoning tokens](https://broadrouter.com/glossary/reasoning-tokens/) count toward `max_tokens`;
-   whether usage is reported at the end of a stream;
-   rate limits and error codes.

## On BroadNet Inference

BroadNet Inference serves `POST /v1/chat/completions`, `POST /v1/audio/transcriptions` and `GET /v1/models` at `https://inference.broadnet.ai/v1`. Keys are sent only as `Authorization: Bearer <key>`. The [Python](https://broadrouter.com/guides/openai-python-sdk/) and [Node](https://broadrouter.com/guides/openai-node-sdk/) guides show full setups, and [LangChain](https://broadrouter.com/guides/langchain-openai-base-url/) works the same way.

Two differences to plan for: DeepSeek V4.1 Flash, GLM 5.3 and Qwen3.8 27B reason before answering, and the reasoning counts toward `max_tokens`. And a pay-as-you-go key allows 30 requests a minute and 4 at once. The [migration checklist](https://broadrouter.com/blog/openai-compatible-api-migration-checklist/) covers the rest.

## Common mistakes

-   Keeping an OpenAI model name such as `gpt-6-astra` (OpenAI’s flagship on its models page, checked 2026-11-15). Use the provider’s model ID.
-   Assuming a parameter works because the request succeeded. Some providers ignore unknown fields silently.

## Questions

### Does OpenAI-compatible mean every OpenAI feature works?

No. It means the core request and response shapes match. Individual fields may be ignored or rejected. Anthropic's compatibility layer, for example, documents fields it ignores and ones that return a 400 error. Read the provider's list before you rely on a parameter.

### Do I need a different SDK?

No. The official OpenAI SDKs accept a custom base URL. In Python pass base\_url, in Node pass baseURL, or set the OPENAI\_BASE\_URL environment variable.

### Which endpoints does BroadNet Inference support?

POST /v1/chat/completions for chat and POST /v1/audio/transcriptions for speech to text. GET /v1/models also exists; BroadNet's docs describe it as public catalogue metadata for external monitors, so take request model IDs from the API reference.

## See also

-   [Base URL](https://broadrouter.com/glossary/base-url/) (term)
-   [API key](https://broadrouter.com/glossary/api-key/) (term)
-   [LLM router](https://broadrouter.com/glossary/llm-router/) (term)
-   [Streaming](https://broadrouter.com/glossary/streaming/) (term)
-   [Inference provider](https://broadrouter.com/glossary/inference-provider/) (term)
-   [Server-sent events (SSE)](https://broadrouter.com/glossary/sse/) (term)
-   [Chat Completions API](https://broadrouter.com/glossary/chat-completions-api/) (term)
-   [Use the OpenAI Python SDK with BroadNet Inference](https://broadrouter.com/guides/openai-python-sdk/) (guide)
-   [Use the OpenAI Node.js SDK with BroadNet Inference](https://broadrouter.com/guides/openai-node-sdk/) (guide)
-   [Use LangChain with BroadNet Inference](https://broadrouter.com/guides/langchain-openai-base-url/) (guide)
-   [First request to BroadNet Inference with curl](https://broadrouter.com/guides/curl-quickstart/) (guide)
-   [Switching to an OpenAI-compatible API: a migration checklist](https://broadrouter.com/blog/openai-compatible-api-migration-checklist/) (article)
-   [OpenRouter vs a flat-rate plan for AI agents: which costs less?](https://broadrouter.com/blog/openrouter-alternative-flat-rate/) (article)

Try it on your real workload. New accounts start with $5 of credit for Gemma and transcription. DeepSeek, GLM and Qwen3.8 need a top-up.

[Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=glossary-openai-compatible-api&utm_content=page-cta) ·

**Sources**

-   [OpenAI API reference, create chat completion](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create)
-   [Anthropic, OpenAI SDK compatibility and its limitations](https://platform.claude.com/docs/en/api/openai-sdk)
-   [OpenAI Python SDK (base\_url and OPENAI\_BASE\_URL)](https://github.com/openai/openai-python)
-   [BroadNet Inference API reference](https://inference.broadnet.ai/docs?utm_source=broadrouter&utm_medium=referral&utm_campaign=glossary-openai-compatible-api&utm_content=sources)
-   [OpenAI, Models (checked 2026-11-15)](https://developers.openai.com/api/docs/models)
