mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-06-16 21:03:58 +08:00
fix(providers): retry OpenAI model discovery without auth on failure
When the OpenAI-compatible endpoint rejects the first authenticated /models request (some upstreams expose the route unauthenticated, or the configured key only covers chat completions), retry once with no key and no custom headers before surfacing the original error so the discovery panel can populate.
This commit is contained in:
@@ -103,7 +103,22 @@ export function useModelDiscovery(
|
||||
const entryKey = (firstEntry?.apiKey ?? '').trim();
|
||||
const entryHeaders = parseHeadersText(firstEntry?.headersText ?? '');
|
||||
const headers = { ...baseHeaders, ...entryHeaders };
|
||||
next = await modelsApi.fetchModelsViaApiCall(baseUrl, entryKey, headers);
|
||||
try {
|
||||
next = await modelsApi.fetchModelsViaApiCall(
|
||||
baseUrl,
|
||||
entryKey,
|
||||
headers
|
||||
);
|
||||
} catch (firstErr) {
|
||||
// Some OpenAI-compatible endpoints expose /models without auth, or
|
||||
// reject the configured key for the discovery route. Retry once
|
||||
// without any auth/headers before surfacing the original error.
|
||||
try {
|
||||
next = await modelsApi.fetchModelsViaApiCall(baseUrl);
|
||||
} catch {
|
||||
throw firstErr;
|
||||
}
|
||||
}
|
||||
}
|
||||
setModels(next ?? []);
|
||||
setHasFetched(true);
|
||||
|
||||
Reference in New Issue
Block a user