diff --git a/packages/llms/src/utils.ts b/packages/llms/src/utils.ts index 3d78af1..e716a76 100644 --- a/packages/llms/src/utils.ts +++ b/packages/llms/src/utils.ts @@ -209,8 +209,12 @@ export function normalizeModelName(modelName: string): string { export function getProvider(baseURL?: string): 'openrouter' | undefined { if (!baseURL) return undefined - const url = new URL(baseURL) - const hostname = url.hostname - if (hostname === 'openrouter.ai') return 'openrouter' - return undefined + try { + const url = new URL(baseURL) + const hostname = url.hostname + if (hostname === 'openrouter.ai') return 'openrouter' + return undefined + } catch (e) { + return undefined + } }