Everyone talks about token pricing. Nobody talks about the code it
takes to actually switch models.
Last month I went DeepSeek → Qwen → GLM → back to DeepSeek.
Here's what each switch cost me beyond the API bill.
Day 1: DeepSeek → Qwen
DeepSeek was rate-limiting me. Qwen had more capacity.
Simple switch, right? Just change the model name?
# Before
response = openai.OpenAI(
api_key="sk-deepseek-xxx",
base_url="https://api.deepseek.com/v1"
).chat.completions.create(model="deepseek-chat", ...)
# After
response = openai.OpenAI(
api_key="sk-qwen-xxx",
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
).chat.completions.create(model="qwen-max", ...)
Okay, two lines changed. But then:
- Qwen uses a different chat template — my system prompts broke
- The response format was subtly different — my parser crashed
- Rate limits work differently — my retry logic needed rework
Real cost: 3 hours of debugging.
Day 4: Qwen → GLM
Needed better Chinese reasoning for a project.
response = openai.OpenAI(
api_key="glm-key-xxx",
base_url="https://open.bigmodel.cn/api/paas/v4"
).chat.completions.create(model="glm-4-plus", ...)
This time I was smarter. I abstracted the provider logic into a config file.
PROVIDERS = {
"deepseek": {"key": "...", "url": "..."},
"qwen": {"key": "...", "url": "..."},
"glm": {"key": "...", "url": "..."},
}
But now I had 4 API keys to rotate. 4 billing dashboards to check.
4 rate limit ceilings to track.
Real cost: ongoing maintenance overhead.
The fix I should have used from day one
An API gateway. One key. One endpoint.
client = openai.OpenAI(
api_key="mb-xxx",
base_url="https://aibridge-api.com/v1"
)
# DeepSeek
client.chat.completions.create(model="deepseek-chat", ...)
# Qwen
client.chat.completions.create(model="qwen-max", ...)
# GLM
client.chat.completions.create(model="glm-4-plus", ...)
Same code. Same endpoint. Same key. Just change the model string.
No provider SDKs to install. No billing dashboards to juggle.
No rate limit surprises — the gateway handles throttling for you.
What I actually gained
| Before | After |
|---|---|
| 4 API keys | 1 API key |
| 4 billing pages | 1 dashboard |
| Model switch = code change | Model switch = 1 string |
| Rate limit surprises | Gateway-level throttling |
| Testing a new model = 30 min | Testing a new model = 2 min |
The real cost of model switching isn't the tokens. It's the
context-switching, the config drift, the "why is this suddenly
failing at 2 AM" incidents.
The lesson
If your app calls more than one AI model — or if you think it might
in the future — abstract the provider layer early. Whether you use
a gateway or build your own router, don't hardcode provider details
into your application code.
I use AIBridge (14 models, OpenAI-compatible, free tier starts at
500K tokens/month) but the principle applies regardless of tool.
The model your app needs in December is not the model you're using
in July. Build for the switch.





Top comments (0)