Short answer: point the OpenAI SDK at an OpenAI-compatible gateway and change only the model string. Every gateway in this space works that way; the real difference is how you pay. Per-token routers such as OpenRouter and Requesty pass through provider token prices plus a fee. APIClaw, which I build, charges a flat $19 to $129 a month for a daily request quota with no per-token metering, across Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, Mistral, Llama, Cohere, Grok and more, and has a free 50-request trial. It fits solo developers and small teams who call several model families every day and want the bill to be the same number each month. If you make a few dozen calls a week, a per-token router is cheaper.
Disclosure: I build APIClaw, so weigh my view accordingly. This article was written with AI assistance and checked by me. Competitor figures come from their own pricing pages, read in October 2026.
Why one key works at all
Most model vendors now accept, or are fronted by gateways that accept, the OpenAI Chat Completions format: a POST /v1/chat/completions with model and messages. A gateway holds the upstream provider accounts and translates where needed. From your code's point of view there is one base URL, one API key, and a model name that selects Claude, GPT, DeepSeek or Qwen.
That means three practical things:
- You keep one secret in your environment instead of four.
- Swapping a model is a config change, not a new SDK.
- Fallbacks between vendors become a loop over model names.
The gateways compared (prices checked Oct 2026)
| Gateway | How you pay | Fee or limit | Notes |
|---|---|---|---|
| OpenRouter | Prepaid credits, per token at provider list price | 5.5% fee on credit purchases (Standard), 8% (Business) | Free models capped at 50 requests/day, 1,000/day after $10 of credits |
| Requesty | Per token | Provider price plus 5% | Free tier on free models, 200 requests/day |
| Flatkey | Per token, below official list price on some models | Discounts shown per model on its site | 100+ models, OpenAI-compatible router |
| Electron Hub | Monthly plan that buys weekly credits | $10 to $249/month; $8 to $200 weekly credits; 10 to 100 requests/minute | Credits refill Sundays 21:00 UTC |
| APIClaw | Flat monthly | $19 to $129/month for 500 to 8,000 requests/day; no per-token metering | Free 50-request trial; crypto on site, other methods via support |
I only listed numbers I could read on each vendor's page this month. I haven't benchmarked latency, so this is a pricing map rather than a review. A longer side-by-side lives in this comparison of OpenAI-compatible API gateways.
The code: one client, four model families
Install the official SDK (pip install openai) and set two environment variables:
export OPENAI_BASE_URL="https://apiclaw.biz/v1"
export OPENAI_API_KEY="sk-your-apiclaw-key"
The SDK reads both automatically, so the client needs no arguments:
from openai import OpenAI
client = OpenAI() # picks up OPENAI_BASE_URL and OPENAI_API_KEY
MODELS = {
"claude": "apiclaw/claude-sonnet-5.5",
"gpt": "apiclaw/gpt-6-sol",
"deepseek": "apiclaw/deepseek-v4-pro",
"qwen": "apiclaw/qwen3.8-max-0902",
}
def ask(family: str, prompt: str) -> str:
resp = client.chat.completions.create(
model=MODELS[family],
messages=[{"role": "user", "content": prompt}],
max_tokens=400,
)
return resp.choices[0].message.content
for family in MODELS:
print(f"--- {family}")
print(ask(family, "Explain a Python context manager in two sentences."))
Nothing in that loop knows which vendor it's talking to. The same pattern works in Node:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://apiclaw.biz/v1",
apiKey: process.env.APICLAW_API_KEY,
});
const res = await client.chat.completions.create({
model: "apiclaw/deepseek-v4-pro",
messages: [{ role: "user", content: "Write a regex for ISO dates." }],
});
console.log(res.choices[0].message.content);
Pick the model per task, not per project
Once switching is free, routing by task is the useful step. A small table in config is enough:
ROUTES = {
"code_review": "apiclaw/claude-sonnet-5.5",
"bulk_summaries": "apiclaw/deepseek-v4-flash",
"multilingual": "apiclaw/qwen3.8-max-0902",
"general": "apiclaw/gpt-6-sol",
}
def run(task: str, prompt: str) -> str:
model = ROUTES.get(task, ROUTES["general"])
return client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": prompt}],
).choices[0].message.content
Under per-token pricing, you route cheap jobs to cheap models to save money. Under a request quota every call costs the same one request, so you can route purely on quality and keep the cheap models for latency-sensitive work.
A cross-vendor fallback in ten lines
Different vendors fail at different times, which is the main reliability win of one key:
from openai import APIError, RateLimitError
FALLBACK = ["apiclaw/claude-sonnet-5.5", "apiclaw/gpt-6-sol", "apiclaw/deepseek-v4-pro"]
def ask_with_fallback(prompt: str) -> str:
last_err = None
for model in FALLBACK:
try:
r = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": prompt}],
timeout=60,
)
return r.choices[0].message.content
except (RateLimitError, APIError) as e:
last_err = e
raise last_err
Keep the list short. Three families from different vendors covers nearly every outage without hiding real bugs behind endless retries.
Things that still differ between models
One key normalises the request format, not the models. Watch for these:
-
Context windows and output limits vary by model. Set
max_tokensexplicitly instead of relying on defaults. -
Tool calling works through the same
toolsparameter, but smaller models follow complex schemas less reliably. Test each model you route tool calls to. - System prompt sensitivity differs. A prompt tuned for Claude may need a line or two of changes for Qwen.
- Reasoning models may return extra reasoning content or take longer. Give them a longer timeout.
When APIClaw isn't the right choice
If your total usage is a handful of calls a day, a per-token router will cost less than $19 a month. If you need SSO, audit logs or a signed enterprise SLA today, Electron Hub's higher tiers or OpenRouter's enterprise plan cover that and APIClaw doesn't advertise it. If your traffic is extremely bursty, such as 20,000 calls on one day and none for a week, a daily request quota is the wrong shape and credits that roll over suit you better.
Switching an existing project
If your code already uses the OpenAI SDK, the switch is two lines of environment:
export OPENAI_BASE_URL="https://apiclaw.biz/v1"
export OPENAI_API_KEY="sk-your-apiclaw-key"
Then change your model= strings to the IDs your gateway lists. Ready-made configs for Cursor, Cline, Aider, LangChain and Claude Code are in these setup examples.
FAQ
Can I use Claude with the OpenAI Python SDK?
Yes, through an OpenAI-compatible gateway. You keep the OpenAI SDK and pass a Claude model ID such as apiclaw/claude-sonnet-5.5 as the model.
Is there one API key for every major LLM?
Not from the model vendors themselves. Gateways such as OpenRouter, Requesty, Electron Hub and APIClaw give you one key that reaches many vendors.
Do I need separate SDKs for DeepSeek and Qwen?
No. Both are reachable with the OpenAI SDK through a compatible endpoint; only the model name changes.
Is a per-token router or a flat plan cheaper?
It depends on volume. Light, irregular use is cheaper per token. Steady daily use with long prompts usually comes out cheaper on a flat request quota, because prompt size doesn't change the price.
Does switching models break streaming or JSON mode?
Streaming works the same way through stream=True. JSON mode and tool calling depend on the model, so test the specific models you rely on.
Top comments (0)