Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix(routing): implement embedding combos, local provider validation bypass, and resolve migration collisions
diegosouzapw5ed96f507233
diff --git a/open-sse/services/contextManager.ts b/open-sse/services/contextManager.tsindex ccf3478653..338afa149a 100644--- a/open-sse/services/contextManager.ts+++ b/open-sse/services/contextManager.ts@@ -128,7 +128,7 @@ export function compressContext(let messages = [...body.messages];let currentTokens = estimateTokens(JSON.stringify(messages));- const stats = { original: currentTokens, layers: [] };+ const stats = { original: currentTokens, layers: [] as { name: string; tokens: number }[] };// Already fitsif (currentTokens <= targetTokens) {diff --git a/src/lib/db/migrations/041_session_account_affinity.sql b/src/lib/db/migrations/041_session_account_affinity.sqldeleted file mode 100644index 5a93707fb3..0000000000--- a/src/lib/db/migrations/041_session_account_affinity.sql+++ /dev/null@@ -1,11 +0,0 @@-CREATE TABLE IF NOT EXISTS session_account_affinity (- session_key TEXT NOT NULL,- provider TEXT NOT NULL,- connection_id TEXT NOT NULL,- created_at INTEGER NOT NULL,- last_seen_at INTEGER NOT NULL,- PRIMARY KEY (session_key, provider)-);--CREATE INDEX IF NOT EXISTS idx_saa_provider ON session_account_affinity(provider);-CREATE INDEX IF NOT EXISTS idx_saa_last_seen ON session_account_affinity(last_seen_at);diff --git a/src/lib/db/migrations/055_command_code_auth_sessions.sql b/src/lib/db/migrations/058_command_code_auth_sessions.sqlsimilarity index 100%rename from src/lib/db/migrations/055_command_code_auth_sessions.sqlrename to src/lib/db/migrations/058_command_code_auth_sessions.sqldiff --git a/src/lib/embeddings/service.ts b/src/lib/embeddings/service.tsindex 41d8a0f1c6..99db52255d 100644--- a/src/lib/embeddings/service.ts+++ b/src/lib/embeddings/service.ts@@ -11,7 +11,8 @@ import { HTTP_STATUS } from "@omniroute/open-sse/config/constants.ts";import * as log from "@/sse/utils/logger";import { toJsonErrorPayload } from "@/shared/utils/upstreamError";import { getProviderCredentials, clearRecoveredProviderState } from "@/sse/services/auth";-import { getProviderNodes } from "@/lib/localDb";+import { getProviderNodes, getComboByName, getCombos, getDatabaseSettings } from "@/lib/localDb";+import { handleComboChat } from "@omniroute/open-sse/services/combo.ts";type ValidatedEmbeddingBody = Record<string, unknown> & { model: string };@@ -30,6 +31,42 @@ export async function createEmbeddingResponse(body: ValidatedEmbeddingBody,options: EmbeddingHandlerOptions = {}): Promise<Response> {+ const modelStr = body.model;++ if (!modelStr.includes("/")) {+ try {+ const combo = await getComboByName(modelStr);+ if (combo) {+ let allCombos = [];+ try {+ allCombos = await getCombos();+ } catch {}++ let settings = {};+ try {+ settings = getDatabaseSettings();+ } catch {}++ return handleComboChat({+ body,+ combo,+ handleSingleModel: async (reqBody: any, targetModelStr: string, target?: any) => {+ const newBody = { ...reqBody, model: targetModelStr };+ return createEmbeddingResponse(newBody, {+ ...options,+ connectionId: target?.connectionId || options.connectionId,+ });+ },+ log,+ settings,+ allCombos,+ signal: undefined,+ });+ }+ } catch (err) {+ log.error("EMBED", `Combo resolution failed for ${modelStr}: ${err}`);+ }+ }let dynamicProviders: ReturnType<typeof buildDynamicEmbeddingProvider>[] = [];try {const nodes = (await getProviderNodes()) as unknown as EmbeddingProviderNodeRow[];diff --git a/src/lib/providers/validation.ts b/src/lib/providers/validation.tsindex b9e599edcf..64b9bf7a2c 100644--- a/src/lib/providers/validation.ts+++ b/src/lib/providers/validation.ts@@ -260,18 +260,18 @@ function buildTokenHeaders(apiKey: string, providerSpecificData: any = {}) {return applyCustomUserAgent(headers, providerSpecificData);}-async function validationRead(url: string, init: RequestInit) {+async function validationRead(url: string, init: RequestInit, isLocal: boolean = false) {return safeOutboundFetch(url, {...SAFE_OUTBOUND_FETCH_PRESETS.validationRead,- guard: getProviderOutboundGuard(),+ guard: isLocal ? "none" : getProviderOutboundGuard(),...init,});}-async function validationWrite(url: string, init: RequestInit) {+async function validationWrite(url: string, init: RequestInit, isLocal: boolean = false) {return safeOutboundFetch(url, {...SAFE_OUTBOUND_FETCH_PRESETS.validationWrite,- guard: getProviderOutboundGuard(),+ guard: isLocal ? "none" : getProviderOutboundGuard(),...init,});}@@ -293,88 +293,106 @@ function toValidationErrorResult(error: unknown) {}async function validateOpenAILikeProvider({- provider,apiKey,baseUrl,- providerSpecificData = {},- modelId = "gpt-4o-mini",- modelsUrl: customModelsUrl,-}: {- provider: string;- apiKey: string;- baseUrl: string;- providerSpecificData?: any;- modelId?: string;- modelsUrl?: string;-}) {- if (!baseUrl) {- return { valid: false, error: "Missing base URL" };- }-- const modelsUrl = customModelsUrl || addModelsSuffix(baseUrl);- if (!modelsUrl) {- return { valid: false, error: "Invalid models endpoint" };- }+ headers = {},+ modelId = "gpt-3.5-turbo",+ providerSpecificData,+ modelsUrl = "",+ isLocal = false,+}: any) {+ try {+ const customModelsUrl = modelsUrl?.trim() || "";+ const endpointUrl = customModelsUrl+ ? customModelsUrl.startsWith("http")+ ? customModelsUrl+ : `${baseUrl.replace(/\/+$/, "")}/${customModelsUrl.replace(/^\/+/, "")}`+ : `${baseUrl}/models`;++ const requestUrl =+ typeof providerSpecificData?.modelsUrl === "string" &&+ providerSpecificData.modelsUrl.trim() !== ""+ ? providerSpecificData.modelsUrl.trim()+ : endpointUrl;++ const response = await validationRead(+ requestUrl,+ {+ headers: {+ ...headers,+ ...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),+ },+ },+ isLocal+ );- const modelsRes = await validationRead(modelsUrl, {- method: "GET",- headers: buildBearerHeaders(apiKey, providerSpecificData),- });+ if (response.ok) {+ return { valid: true, error: null };+ }- if (modelsRes.ok) {- return { valid: true, error: null };- }+ if (response.status === 401 || response.status === 403) {+ return { valid: false, error: "Invalid API key" };+ }- if (modelsRes.status === 401 || modelsRes.status === 403) {- return { valid: false, error: "Invalid API key" };- }+ const chatUrl = resolveChatUrl("openai", baseUrl, providerSpecificData);+ if (!chatUrl) {+ return { valid: false, error: `Validation failed: ${response.status}` };+ }- const chatUrl = resolveChatUrl(provider, baseUrl, providerSpecificData);- if (!chatUrl) {- return { valid: false, error: `Validation failed: ${modelsRes.status}` };- }+ const testModelId = (providerSpecificData as any)?.validationModelId || modelId;- const testModelId = (providerSpecificData as any)?.validationModelId || modelId;+ const testBody = {+ model: testModelId,+ messages: [{ role: "user", content: "test" }],+ max_tokens: 1,+ };- const testBody = {- model: testModelId,- messages: [{ role: "user", content: "test" }],- max_tokens: 1,- };+ const chatRes = await validationWrite(+ chatUrl,+ {+ method: "POST",+ headers: {+ ...headers,+ ...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),+ },+ body: JSON.stringify(testBody),+ },+ isLocal+ );- const chatRes = await validationWrite(chatUrl, {- method: "POST",- headers: buildBearerHeaders(apiKey, providerSpecificData),- body: JSON.stringify(testBody),- });+ if (chatRes.ok) {+ return { valid: true, error: null };+ }- if (chatRes.ok) {- return { valid: true, error: null };- }+ if (chatRes.status === 401 || chatRes.status === 403) {+ return { valid: false, error: "Invalid API key" };+ }- if (chatRes.status === 401 || chatRes.status === 403) {- return { valid: false, error: "Invalid API key" };- }+ if (chatRes.status === 404 || chatRes.status === 405) {+ return { valid: false, error: "Provider validation endpoint not supported" };+ }- if (chatRes.status === 404 || chatRes.status === 405) {- return { valid: false, error: "Provider validation endpoint not supported" };- }+ if (chatRes.status >= 500) {+ return { valid: false, error: `Provider unavailable (${chatRes.status})` };+ }- if (chatRes.status >= 500) {- return { valid: false, error: `Provider unavailable (${chatRes.status})` };+ return { valid: true, error: null };+ } catch (error: any) {+ return toValidationErrorResult(error);}-- // 4xx other than auth (e.g., invalid model/body) usually means auth passed.- return { valid: true, error: null };}-async function validateDirectChatProvider({ url, headers, body, providerSpecificData = {} }: any) {+async function validateDirectChatProvider({ url, headers, body, providerSpecificData = {}, isLocal = false }: any) {try {- const response = await validationWrite(url, {- method: "POST",- headers: applyCustomUserAgent(headers, providerSpecificData),- body: JSON.stringify(body),- });+ const response = await validationWrite(+ url,+ {+ method: "POST",+ headers: applyCustomUserAgent(headers, providerSpecificData),+ body: JSON.stringify(body),+ },+ isLocal+ );if (response.status === 401 || response.status === 403) {return { valid: false, error: "Invalid API key" };@@ -590,59 +608,80 @@ async function validateRerankApiProvider({ apiKey, providerSpecificData = {}, urasync function validateAnthropicLikeProvider({apiKey,baseUrl,- modelId,+ modelId = "claude-3-5-sonnet-20240620",headers = {},providerSpecificData = {},+ isLocal = false,}: any) {- if (!baseUrl) {- return { valid: false, error: "Missing base URL" };- }+ try {+ const requestUrl =+ typeof providerSpecificData?.modelsUrl === "string" &&+ providerSpecificData.modelsUrl.trim() !== ""+ ? providerSpecificData.modelsUrl.trim()+ : `${baseUrl}/models`;++ const response = await validationRead(+ requestUrl,+ {+ headers: {+ "anthropic-version": "2023-06-01",+ ...headers,+ },+ },+ isLocal+ );- // OAuth tokens need the same Claude Code cloak as production traffic in- // base.ts; a bare validation request gets flagged on the user:sessions:- // claude_code scope.- if (typeof apiKey === "string" && apiKey.startsWith("sk-ant-oat")) {- return validateClaudeOAuthInline({ apiKey, modelId, providerSpecificData });- }+ if (!baseUrl) {+ return { valid: false, error: "Missing base URL" };+ }- const requestHeaders = applyCustomUserAgent(- {- "Content-Type": "application/json",- ...headers,- },- providerSpecificData- );+ if (typeof apiKey === "string" && apiKey.startsWith("sk-ant-oat")) {+ return validateClaudeOAuthInline({ apiKey, modelId, providerSpecificData });+ }- if (!requestHeaders["x-api-key"] && !requestHeaders["X-API-Key"]) {- requestHeaders["x-api-key"] = apiKey;- }+ const requestHeaders = applyCustomUserAgent(+ {+ "Content-Type": "application/json",+ ...headers,+ },+ providerSpecificData+ );- if (!requestHeaders["anthropic-version"] && !requestHeaders["Anthropic-Version"]) {- requestHeaders["anthropic-version"] = "2023-06-01";- }+ if (!requestHeaders["x-api-key"] && !requestHeaders["X-API-Key"]) {+ requestHeaders["x-api-key"] = apiKey;+ }- const testModelId =- providerSpecificData?.validationModelId || modelId || "claude-3-5-sonnet-20241022";+ if (!requestHeaders["anthropic-version"] && !requestHeaders["Anthropic-Version"]) {+ requestHeaders["anthropic-version"] = "2023-06-01";+ }- const response = await validationWrite(baseUrl, {- method: "POST",- headers: requestHeaders,- body: JSON.stringify({- model: testModelId,- max_tokens: 1,- messages: [{ role: "user", content: "test" }],- }),- });+ const testModelId =+ providerSpecificData?.validationModelId || modelId || "claude-3-5-sonnet-20241022";- if (response.status === 401 || response.status === 403) {- return { valid: false, error: "Invalid API key" };- }+ const chatResponse = await validationWrite(+ baseUrl,+ {+ method: "POST",+ headers: requestHeaders,+ body: JSON.stringify({+ model: testModelId,+ max_tokens: 1,+ messages: [{ role: "user", content: "test" }],+ }),+ },+ isLocal+ );++ if (chatResponse.status === 401 || chatResponse.status === 403) {+ return { valid: false, error: "Invalid API key" };+ }- return { valid: true, error: null };+ return { valid: true, error: null };+ } catch (error: any) {+ return toValidationErrorResult(error);+ }}-// Probe a Claude OAuth credential through the same executor that handles-// production traffic so the cloak/signing/identity logic isn't duplicated.async function validateClaudeOAuthInline({apiKey,modelId,@@ -673,7 +712,6 @@ async function validateClaudeOAuthInline({if (response.status >= 500) {return { valid: false, error: `Provider unavailable (${response.status})` };}- // 2xx and non-auth 4xx (429 quota, 400 model) both mean the token is valid.return { valid: true, error: null };} catch (error: any) {return toValidationErrorResult(error);@@ -683,76 +721,79 @@ async function validateClaudeOAuthInline({async function validateGeminiLikeProvider({apiKey,baseUrl,- authType,providerSpecificData = {},+ authType = "query",+ isLocal = false,}: any) {- if (!baseUrl) {- return { valid: false, error: "Missing base URL" };- }-- // Use the correct auth header based on provider config:- // - gemini (API key): x-goog-api-key- // - gemini-cli (OAuth): Bearer token- const headers: Record<string, string> = { "Content-Type": "application/json" };- if (authType === "oauth") {- headers["Authorization"] = `Bearer ${apiKey}`;- } else {- headers["x-goog-api-key"] = apiKey;- }- applyCustomUserAgent(headers, providerSpecificData);+ try {+ const requestUrl =+ typeof providerSpecificData?.modelsUrl === "string" &&+ providerSpecificData.modelsUrl.trim() !== ""+ ? providerSpecificData.modelsUrl.trim()+ : `${baseUrl}/models`;+ const urlWithKey =+ authType === "query" ? `${requestUrl}?key=${encodeURIComponent(apiKey)}` : requestUrl;+ const headers = authType === "header" ? { "x-goog-api-key": apiKey } : {};++ const response = await validationRead(+ urlWithKey,+ {+ headers,+ },+ isLocal+ );- const response = await validationRead(baseUrl, { method: "GET", headers });+ if (!baseUrl) {+ return { valid: false, error: "Missing base URL" };+ }- if (response.ok) {- return { valid: true, error: null };- }+ if (response.ok) {+ return { valid: true, error: null };+ }- // 429 = rate limited, but auth is valid- if (response.status === 429) {- return { valid: true, error: null };- }+ if (response.status === 429) {+ return { valid: true, error: null };+ }- // Google returns 400 (not 401/403) for invalid API keys on the models endpoint.- // Parse the response body to detect auth failures.- if (response.status === 400 || response.status === 401 || response.status === 403) {- const isAuthError = (body: any) => {- const message = (body?.error?.message || "").toLowerCase();- const reason = body?.error?.details?.[0]?.reason || "";- const status = body?.error?.status || "";- const authPatterns = [- "api key not valid",- "api key expired",- "api key invalid",- "API_KEY_INVALID",- "API_KEY_EXPIRED",- "PERMISSION_DENIED",- "UNAUTHENTICATED",- ];- return authPatterns.some(- (p) => message.includes(p.toLowerCase()) || reason === p || status === p- );- };+ if (response.status === 400 || response.status === 401 || response.status === 403) {+ const isAuthError = (body: any) => {+ const message = (body?.error?.message || "").toLowerCase();+ const reason = body?.error?.details?.[0]?.reason || "";+ const status = body?.error?.status || "";+ const authPatterns = [+ "api key not valid",+ "api key expired",+ "api key invalid",+ "API_KEY_INVALID",+ "API_KEY_EXPIRED",+ "PERMISSION_DENIED",+ "UNAUTHENTICATED",+ ];+ return authPatterns.some(+ (p) => message.includes(p.toLowerCase()) || reason === p || status === p+ );+ };- try {- const body = await response.json();- if (isAuthError(body)) {- return { valid: false, error: "Invalid API key" };- }- // 401/403 are always auth failures even without matching patterns- if (response.status === 401 || response.status === 403) {- return { valid: false, error: "Invalid API key" };- }- } catch {- // Unparseable body — 401/403 are always auth failures- if (response.status === 401 || response.status === 403) {+ try {+ const body = await response.json();+ if (isAuthError(body)) {+ return { valid: false, error: "Invalid API key" };+ }+ if (response.status === 401 || response.status === 403) {+ return { valid: false, error: "Invalid API key" };+ }+ } catch {+ if (response.status === 401 || response.status === 403) {+ return { valid: false, error: "Invalid API key" };+ }return { valid: false, error: "Invalid API key" };}- // 400 without parseable body — likely auth issue for Gemini- return { valid: false, error: "Invalid API key" };}- }- return { valid: false, error: `Validation failed: ${response.status}` };+ return { valid: false, error: `Validation failed: ${response.status}` };+ } catch (error: any) {+ return toValidationErrorResult(error);+ }}// ── Specialty providers (non-standard APIs) ──@@ -2134,7 +2175,7 @@ async function validateOpenAICompatibleProvider({ apiKey, providerSpecificData =}}-async function validateAnthropicCompatibleProvider({ apiKey, providerSpecificData = {} }: any) {+async function validateAnthropicCompatibleProvider({ apiKey, providerSpecificData = {}, isLocal = false }: any) {let baseUrl = normalizeAnthropicBaseUrl(providerSpecificData.baseUrl);if (!baseUrl) {return { valid: false, error: "No base URL configured for Anthropic compatible provider" };@@ -2157,7 +2198,8 @@ async function validateAnthropicCompatibleProvider({ apiKey, providerSpecificDat{method: "GET",headers,- }+ },+ isLocal);if (modelsRes.ok) {@@ -2184,7 +2226,8 @@ async function validateAnthropicCompatibleProvider({ apiKey, providerSpecificDatmax_tokens: 1,messages: [{ role: "user", content: "test" }],}),- }+ },+ isLocal);if (messagesRes.status === 401 || messagesRes.status === 403) {@@ -2280,15 +2323,31 @@ export async function validateClaudeCodeCompatibleProvider({// ── Search provider validators (factored) ──+async function validateGenericProvider(+ baseUrl: string,+ apiKey: string,+ providerSpecificData: any = {},+ provider: string,+ isLocal: boolean = false+) {+ const config = SEARCH_VALIDATOR_CONFIGS[provider];+ if (!config) {+ return { valid: false, error: "Validator not found", unsupported: true };+ }+ const { url, init } = config(apiKey, providerSpecificData);+ return validateSearchProvider(url, init, providerSpecificData, isLocal);+}+async function validateSearchProvider(url: string,init: RequestInit,- providerSpecificData: any = {}+ providerSpecificData: any = {},+ isLocal: boolean = false): Promise<{ valid: boolean; error: string | null; unsupported: false }> {try {const response = await safeOutboundFetch(url, {...SAFE_OUTBOUND_FETCH_PRESETS.validationWrite,- guard: getProviderOutboundGuard(),+ guard: isLocal ? "none" : getProviderOutboundGuard(),...withCustomUserAgent(init, providerSpecificData),});if (response.ok) return { valid: true, error: null, unsupported: false };@@ -2813,7 +2872,7 @@ async function validatePerplexityWebProvider({ apiKey, providerSpecificData = {}Origin: "https://www.perplexity.ai",Referer: "https://www.perplexity.ai/","User-Agent":- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/136.0.0.0","X-App-ApiClient": "default","X-App-ApiVersion": "client-1.11.0",...(bearerToken@@ -2882,7 +2941,7 @@ async function validateBlackboxWebProvider({ apiKey, providerSpecificData = {} }Origin: "https://app.blackbox.ai",Referer: "https://app.blackbox.ai/","User-Agent":- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36",+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/147.0.0.0",},providerSpecificData);@@ -2912,7 +2971,7 @@ async function validateBlackboxWebProvider({ apiKey, providerSpecificData = {} }Origin: "https://app.blackbox.ai",Referer: "https://app.blackbox.ai/","User-Agent":- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36",+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/147.0.0.0",},providerSpecificData);@@ -3048,6 +3107,7 @@ async function validateMuseSparkWebProvider({ apiKey, providerSpecificData = {}export async function validateProviderApiKey({ provider, apiKey, providerSpecificData = {} }: any) {const requiresApiKey = !providerAllowsOptionalApiKey(provider);+ const isLocal = isLocalProvider(provider);if (!provider || (requiresApiKey && !apiKey)) {return { valid: false, error: "Provider and API key required", unsupported: false };@@ -3066,7 +3126,11 @@ export async function validateProviderApiKey({ provider, apiKey, providerSpecifiif (isClaudeCodeCompatibleProvider(provider)) {return await validateClaudeCodeCompatibleProvider({ apiKey, providerSpecificData });}- return await validateAnthropicCompatibleProvider({ apiKey, providerSpecificData });+ return await validateAnthropicCompatibleProvider({+ apiKey,+ providerSpecificData,+ isLocal,+ });} catch (error: any) {return toValidationErrorResult(error);}@@ -3112,6 +3176,7 @@ export async function validateProviderApiKey({ provider, apiKey, providerSpecifibaseUrl,modelId: getBedrockValidationModelId(baseUrl),modelsUrl: buildBedrockModelsUrl(baseUrl),+ isLocal,});},modal: ({ apiKey, providerSpecificData }: any) =>@@ -3121,6 +3186,7 @@ export async function validateProviderApiKey({ provider, apiKey, providerSpecifiproviderSpecificData,baseUrl: normalizeBaseUrl(providerSpecificData?.baseUrl || ""),modelId: "Qwen/Qwen3-4B-Thinking-2507-FP8",+ isLocal,}),"nous-research": validateNousResearchProvider,petals: validatePetalsProvider,@@ -3168,7 +3234,7 @@ export async function validateProviderApiKey({ provider, apiKey, providerSpecifimethod: "POST",headers: buildBearerHeaders(apiKey, providerSpecificData),body: "{}",- });+ }, isLocal);if (res.status === 401) {return { valid: false, error: "Invalid API key" };}@@ -3182,7 +3248,7 @@ export async function validateProviderApiKey({ provider, apiKey, providerSpecificonst { parseSAFromApiKey, getAccessToken } =await import("@omniroute/open-sse/executors/vertex.ts");const sa = parseSAFromApiKey(apiKey);- // Validates credentials by successfully exchanging them for a JWT from Google Identity+ // Validates credentials by successfully successfully exchanging them for a JWT from Google Identityawait getAccessToken(sa);return { valid: true, error: null };} catch (error: any) {@@ -3211,7 +3277,7 @@ export async function validateProviderApiKey({ provider, apiKey, providerSpecifimessages: [{ role: "user", content: "test" }],max_tokens: 1,}),- });+ }, isLocal);if (res.status === 401 || res.status === 403) {return { valid: false, error: "Invalid API key" };}@@ -3238,7 +3304,7 @@ export async function validateProviderApiKey({ provider, apiKey, providerSpecifimessages: [{ role: "user", content: "test" }],max_tokens: 1,}),- });+ }, isLocal);if (res.status === 401 || res.status === 403) {return { valid: false, error: "Invalid API key" };}@@ -3254,7 +3320,7 @@ export async function validateProviderApiKey({ provider, apiKey, providerSpecifiid,({ apiKey, providerSpecificData }: any) => {const { url, init } = configFn(apiKey, providerSpecificData);- return validateSearchProvider(url, init, providerSpecificData);+ return validateSearchProvider(url, init, providerSpecificData, isLocal);},])),@@ -3278,6 +3344,7 @@ export async function validateProviderApiKey({ provider, apiKey, providerSpecifiproviderSpecificData,modelId: "local-model",modelsUrl: addModelsSuffix(providerSpecificData?.baseUrl || ""),+ isLocal,});}return { valid: false, error: "Provider validation not supported", unsupported: true };@@ -3294,12 +3361,13 @@ export async function validateProviderApiKey({ provider, apiKey, providerSpecifitry {if (OPENAI_LIKE_FORMATS.has(entry.format)) {return await validateOpenAILikeProvider({- provider,apiKey,baseUrl,+ headers: entry.headers || {},providerSpecificData,modelId,modelsUrl: entry.modelsUrl,+ isLocal,});}@@ -3321,6 +3389,7 @@ export async function validateProviderApiKey({ provider, apiKey, providerSpecifimodelId,headers: requestHeaders,providerSpecificData,+ isLocal,});}@@ -3330,6 +3399,7 @@ export async function validateProviderApiKey({ provider, apiKey, providerSpecifibaseUrl,providerSpecificData,authType: entry.authType,+ isLocal,});}