@fudrouter/fsrouter 0.6.114 → 0.6.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -112,7 +112,7 @@ export async function POST_handler(req, res) {
|
|
|
112
112
|
normalizedBase = normalizedBase.slice(0, -9);
|
|
113
113
|
}
|
|
114
114
|
const modelsUrl = `${normalizedBase}/models`;
|
|
115
|
-
const
|
|
115
|
+
const probeRes = await fetchWithTimeout(modelsUrl, {
|
|
116
116
|
method: "GET",
|
|
117
117
|
headers: {
|
|
118
118
|
"x-api-key": apiKey,
|
|
@@ -120,10 +120,10 @@ export async function POST_handler(req, res) {
|
|
|
120
120
|
"Authorization": `Bearer ${apiKey}`
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
|
-
if (
|
|
123
|
+
if (probeRes.ok)
|
|
124
124
|
return res.json({ valid: true });
|
|
125
125
|
// Auth errors - no point trying chat fallback
|
|
126
|
-
if (
|
|
126
|
+
if (probeRes.status === 401 || probeRes.status === 403) {
|
|
127
127
|
return res.json({ valid: false, error: "API key unauthorized" });
|
|
128
128
|
}
|
|
129
129
|
// Fallback: try chat/completions if modelId provided
|
|
@@ -151,17 +151,17 @@ export async function POST_handler(req, res) {
|
|
|
151
151
|
method: "chat"
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
return res.json({ valid: false, error: getModelsErrorMessage(
|
|
154
|
+
return res.json({ valid: false, error: getModelsErrorMessage(probeRes.status) });
|
|
155
155
|
}
|
|
156
156
|
// OpenAI Compatible Validation (Default)
|
|
157
157
|
const modelsUrl = `${baseUrl.replace(/\/$/, "")}/models`;
|
|
158
|
-
const
|
|
158
|
+
const probeRes = await fetchWithTimeout(modelsUrl, {
|
|
159
159
|
headers: { "Authorization": `Bearer ${apiKey}` },
|
|
160
160
|
});
|
|
161
|
-
if (
|
|
161
|
+
if (probeRes.ok)
|
|
162
162
|
return res.json({ valid: true });
|
|
163
163
|
// Auth errors - no point trying chat fallback
|
|
164
|
-
if (
|
|
164
|
+
if (probeRes.status === 401 || probeRes.status === 403) {
|
|
165
165
|
return res.json({ valid: false, error: "API key unauthorized" });
|
|
166
166
|
}
|
|
167
167
|
// Fallback: try chat/completions if modelId provided
|