OpenAI Compatible API — Use Any LLM with One Endpoint | APIMaster.ai
How the OpenAI-compatible API works: call Claude, DeepSeek, Gemini, and GPT models through a single OpenAI-format endpoint. Drop-in replacement guide with Python examples.
OpenAI Compatible API Guide
The OpenAI API format has become the standard interface for large language models. An "OpenAI-compatible API" accepts the same request format (/v1/chat/completions) and returns responses in the same structure—letting you swap models without changing your code.
APIMaster.ai provides an OpenAI-compatible endpoint for Claude, GPT, DeepSeek, Gemini, and more.
What Is an OpenAI-Compatible API?
Any API that implements these endpoints is "OpenAI-compatible":
| Endpoint | Method | Purpose |
|---|---|---|
/v1/chat/completions |
POST | Generate responses |
/v1/models |
GET | List available models |
/v1/embeddings |
POST | Create embeddings |
The request/response schema is identical to OpenAI's, so any tool that supports OpenAI (LangChain, LiteLLM, Dify, open-webui, etc.) works automatically.
Using APIMaster's OpenAI-Compatible Endpoint
Base URL: https://apimaster.ai/v1
from openai import OpenAI
client = OpenAI(
api_key="YOUR_APIMASTER_KEY",
base_url="https://apimaster.ai/v1",
)
# Call Claude
response = client.chat.completions.create(
model="claude-sonnet-4-6",
messages=[{"role": "user", "content": "Hello from OpenAI-compatible API!"}],
)
# Call DeepSeek
response = client.chat.completions.create(
model="deepseek-v4",
messages=[{"role": "user", "content": "Hello!"}],
)
# Call GPT
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
One client, three providers, zero code changes between them.
Integrating with Popular Frameworks
LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="claude-sonnet-4-6",
openai_api_key="YOUR_APIMASTER_KEY",
openai_api_base="https://apimaster.ai/v1",
)
response = llm.invoke("What is LangChain used for?")
print(response.content)
LiteLLM
import litellm
response = litellm.completion(
model="openai/claude-sonnet-4-6",
api_key="YOUR_APIMASTER_KEY",
api_base="https://apimaster.ai/v1",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
Dify
In Dify's model provider settings:
- Provider: OpenAI-Compatible
- API Key: your APIMaster key
- API Base URL:
https://apimaster.ai/v1 - Model name:
claude-sonnet-4-6orgpt-4o
Open WebUI
docker run -d \
-e OPENAI_API_KEY="YOUR_APIMASTER_KEY" \
-e OPENAI_API_BASE_URL="https://apimaster.ai/v1" \
-p 3000:8080 \
ghcr.io/open-webui/open-webui
Cursor / VS Code AI Extensions
Set Custom OpenAI Base URL to https://apimaster.ai/v1 and use your APIMaster key. Select any model from the available list.
Available Models on APIMaster OpenAI-Compatible Endpoint
Claude (Anthropic)
claude-sonnet-4-6— best valueclaude-opus-4-8— most capableclaude-haiku-4-5— fastest, cheapestclaude-fable-5— creative
GPT (OpenAI)
gpt-5— latest flagshipgpt-4o— multimodalgpt-4o-mini— budget
DeepSeek
deepseek-v4— strong coding, very cheapdeepseek-r1— reasoning
Gemini (Google)
gemini-2.5-pro— long context
See the full list on the models page.
Model Switching at Runtime
MODELS = ["claude-sonnet-4-6", "gpt-4o", "deepseek-v4"]
def compare_models(prompt):
client = OpenAI(api_key="YOUR_KEY", base_url="https://apimaster.ai/v1")
for model in MODELS:
resp = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": prompt}],
max_tokens=200,
)
print(f"\n=== {model} ===")
print(resp.choices[0].message.content)
compare_models("Explain recursion in one paragraph.")
Migrating from OpenAI to OpenAI-Compatible API
Change exactly two lines:
# Before
from openai import OpenAI
client = OpenAI(api_key="sk-...")
# After (APIMaster)
from openai import OpenAI
client = OpenAI(
api_key="YOUR_APIMASTER_KEY", # ← changed
base_url="https://apimaster.ai/v1", # ← added
)
Everything else—models, streaming, function calling, embeddings—stays the same.
Why APIMaster for OpenAI-Compatible API
- All major providers in one endpoint: no separate keys for each provider
- Fingerprint verified: know which model you're actually calling
- Works worldwide: no VPN required for China/Russia users
- Discounted pricing: up to 90% off on select models