APIMaster.ai

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.

How to Use 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-flash",
    messages=[{"role": "user", "content": "Hello!"}],
)

# Call GPT
response = client.chat.completions.create(
    model="gpt-5.4",
    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-6 or gpt-5.4

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 value
  • claude-opus-4-8 — most capable
  • claude-haiku-4-5 — fastest, cheapest

GPT (OpenAI)

  • gpt-5.5 — high-capability GPT-5 series model
  • gpt-5.4 — balanced GPT-5 series model

DeepSeek

  • deepseek-v4-flash — strong coding, very cheap
  • deepseek-v4-pro — 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-5.4", "deepseek-v4-flash"]

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
  • Discounted pricing on select models

Frequently Asked Questions

What is an OpenAI-compatible API? An API that matches OpenAI's Chat Completions endpoint format (POST /v1/chat/completions). Any library or tool built for OpenAI—LangChain, LlamaIndex, PromptFlow—works with an OpenAI-compatible API without code changes.

Which models does APIMaster's OpenAI-compatible API support? GPT-5 series models, GPT-4o, Claude Sonnet 4.6, Claude Opus 4.8, DeepSeek V4 Flash/Pro, Gemini 2.5 Pro, and more. See the full model list.

How do I switch from OpenAI to an OpenAI-compatible API? Change two values: api_key to your APIMaster key and base_url to https://apimaster.ai/v1. All model calls, streaming, tool use, and response parsing work unchanged.

Does APIMaster's API support streaming and function calling? Yes—both are fully supported and use the same interface as the official OpenAI API.

Can I use one API key for multiple model providers? Yes—that's APIMaster's main advantage. One key and one endpoint lets you call GPT, Claude, DeepSeek, and Gemini by just changing the model parameter.

Get API access — one OpenAI-compatible key for GPT, Claude & DeepSeek → · See model pricing →