Most teams don't need a new SDK for every model. They need a single OpenAI-compatible endpoint and a clean baseURL.
The 3 steps
- Create an API key on your gateway.
-
Point the OpenAI SDK at the gateway base URL (usually ending in
/v1). - Keep the rest of your code β chat completions, streaming, tools. Swap the model string when you want GPT, Claude, or Grok.
from openai import OpenAI
client = OpenAI(
api_key="YOUR_KEY",
base_url="https://YOUR_GATEWAY/v1",
)
resp = client.chat.completions.create(
model="gpt-4o-mini", # or a Claude / Grok id your gateway exposes
messages=[{"role": "user", "content": "ping"}],
)
print(resp.choices[0].message.content)
Footgun: Claude Code vs OpenAI clients
-
OpenAI SDK / most OpenAI-compatible clients want the base URL with
/v1. -
Claude Code / Anthropic-style clients often want the base URL without
/v1(they append/v1/messagesthemselves).
If Claude Code 404s on /v1/v1/messages, you double-prefixed the path β not an auth bug.
Longer walkthrough: OpenAI-compatible API guide and the short getting started guide.
What to actually test
Don't only hit chat completions. Check streaming, tool/function calls, long context, and the clients you really use (Claude Code, Codex, Cherry Studio). If those break, "compatible" is marketing.
Cost framing for agents
List $/1M tokens is a vanity metric. Retries, timeouts, and tool failures dominate. Measure cost per successful task.
If you want a managed OpenAI-compatible gateway for GPT / Claude / Grok: APICLAN β signup auto-credits $0.20 so you can make a real call, not a fake demo. USDT wallet top-ups; no card data stored.
Top comments (0)