Set Backup Models: Switch to Claude / Qwen / DeepSeek When OpenAI Fails
Add model fallback in your own application code so a failed OpenAI request can retry with Claude, Qwen, or DeepSeek.
To switch from OpenAI to Claude / Qwen / DeepSeek when a request fails, catch the failure in your application code and retry with another model.
Step 1: Prepare a fallback model list
Open Model Plaza and copy model names available to your account. Prepare one primary model and 2 to 3 fallback models.
const fallbackModels = [
"your-openai-model",
"your-claude-model",
"your-qwen-model",
"your-deepseek-model",
];If your code uses OpenAI-compatible /v1/chat/completions, confirm the fallback models work with that request style. Availability should be verified through Model Plaza and a real test request.
Step 2: Retry only retryable errors
| Error type | Switch model? |
|---|---|
| Network timeout | Yes |
429 | Yes |
Upstream 5xx | Yes |
400 | No, usually a parameter issue |
401 / 403 | No, usually an API Key, quota, or permission issue |
404 | No, usually a model name issue |
JavaScript / TypeScript example
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.ROUTESCOPE_API_KEY,
baseURL: "https://api.routescope.ai/v1",
});
const fallbackModels = [
"your-openai-model",
"your-claude-model",
"your-qwen-model",
"your-deepseek-model",
];
function shouldRetry(error: any) {
const status = error?.status;
return !status || status === 429 || status >= 500;
}
export async function createChatWithFallback(messages: any[]) {
let lastError: unknown;
for (const model of fallbackModels) {
try {
return await client.chat.completions.create({
model,
messages,
});
} catch (error) {
lastError = error;
if (!shouldRetry(error)) {
throw error;
}
}
}
throw lastError;
}Python example
from openai import OpenAI
client = OpenAI(
api_key="sk-your-token",
base_url="https://api.routescope.ai/v1",
)
fallback_models = [
"your-openai-model",
"your-claude-model",
"your-qwen-model",
"your-deepseek-model",
]
def should_retry(error):
status = getattr(error, "status_code", None)
return status is None or status == 429 or status >= 500
def create_chat_with_fallback(messages):
last_error = None
for model in fallback_models:
try:
return client.chat.completions.create(
model=model,
messages=messages,
)
except Exception as error:
last_error = error
if not should_retry(error):
raise
raise last_errorClient tools
If you use a client without custom code, such as an editor extension or desktop client, you usually need to switch models manually. You can save several RouteScope model configurations in the same tool.
| Scenario | What to do |
|---|---|
| Primary model fails occasionally | Manually switch to a backup model and retry. |
| You are building your own application | Use the fallback code above. |
| Your team gave you a unified model name | Use the model name your team provided. |
Verify fallback behavior
For testing, temporarily set the first model name to an unavailable model and confirm your code continues to the next model. Restore the real model name after testing.
In operation records, check:
| Item | What to verify |
|---|---|
| Multiple records | The failed model and successful model are recorded separately. |
| Requested model | Models were tried in the order you configured. |
| Error reason | Only 429, timeouts, or 5xx caused retries. |
| Final cost | Cost is based on the model that eventually succeeds and its output tokens. |
Last updated on
Route Simple Tasks to Qwen / DeepSeek to Reduce Costs
Choose Qwen or DeepSeek in your request or client for summarization, classification, rewriting, and other simple tasks.
OpenAI, Claude, Qwen, DeepSeek Pricing and Use Case Comparison
Compare cost tendencies and use cases across common model families, then verify real usage in Model Plaza and operation records.