diff --git a/src/models.js b/src/models.js index 11aadf1..6c2152a 100644 --- a/src/models.js +++ b/src/models.js @@ -42,13 +42,15 @@ export async function fetchModelsFromEndpoints() { // Collect endpoints to fetch from const endpointsToFetch = [...VLLM_ENDPOINTS]; - // Add custom API endpoint if configured - const apiConfig = await getAPIConfig(); - if (apiConfig.isCustom) { - console.log("🔧 Adding custom API endpoint to model fetch:", apiConfig.endpoint); + // Add custom API endpoint if the checkbox is checked (regardless of current model routing) + const useCustomAPI = localStorage.getItem("useCustomAPI") === "true"; + const customBaseURL = localStorage.getItem("customBaseURL"); + + if (useCustomAPI && customBaseURL) { + console.log("🔧 Adding custom API endpoint to model fetch:", customBaseURL); endpointsToFetch.push({ - id: apiConfig.endpoint, - url: apiConfig.endpoint + id: customBaseURL, + url: customBaseURL }); } else { console.log("🏠 No custom API configured, using default endpoints only"); @@ -64,8 +66,11 @@ export async function fetchModelsFromEndpoints() { }; // Add authorization for custom API - if (endpoint.id === apiConfig.endpoint && apiConfig.isCustom) { - headers["Authorization"] = `Bearer ${apiConfig.apiKey}`; + if (endpoint.id === customBaseURL && useCustomAPI) { + const customAPIKey = localStorage.getItem("customAPIKey"); + if (customAPIKey) { + headers["Authorization"] = `Bearer ${customAPIKey}`; + } } const res = await fetch(`${endpoint.url}/models`, { headers });