fix(openrouter): add ANTHROPIC_API_KEY="" default for OpenRouter profiles

Per OpenRouter requirements, explicitly blank out the Anthropic API key
to prevent conflicts when using OpenRouter's API. The key is visible in
the "Additional Variables" section of the profile editor.
This commit is contained in:
kaitranntt
2025-12-20 23:43:52 -05:00
parent ebc8ee2638
commit 70bc44eb11
2 changed files with 10 additions and 0 deletions
+9
View File
@@ -13,6 +13,11 @@ import {
} from '../../config/unified-config-loader';
import type { ModelMapping, CreateApiProfileResult, RemoveApiProfileResult } from './profile-types';
/** Check if URL is an OpenRouter endpoint */
function isOpenRouterUrl(baseUrl: string): boolean {
return baseUrl.toLowerCase().includes('openrouter.ai');
}
/** Create settings.json file for API profile (legacy format) */
function createSettingsFile(
name: string,
@@ -31,6 +36,8 @@ function createSettingsFile(
ANTHROPIC_DEFAULT_OPUS_MODEL: models.opus,
ANTHROPIC_DEFAULT_SONNET_MODEL: models.sonnet,
ANTHROPIC_DEFAULT_HAIKU_MODEL: models.haiku,
// OpenRouter requires explicitly blanking the API key to prevent conflicts
...(isOpenRouterUrl(baseUrl) && { ANTHROPIC_API_KEY: '' }),
},
};
@@ -82,6 +89,8 @@ function createApiProfileUnified(
ANTHROPIC_DEFAULT_OPUS_MODEL: models.opus,
ANTHROPIC_DEFAULT_SONNET_MODEL: models.sonnet,
ANTHROPIC_DEFAULT_HAIKU_MODEL: models.haiku,
// OpenRouter requires explicitly blanking the API key to prevent conflicts
...(isOpenRouterUrl(baseUrl) && { ANTHROPIC_API_KEY: '' }),
},
};
@@ -111,6 +111,7 @@ export function FriendlyUISection({
'ANTHROPIC_DEFAULT_SONNET_MODEL',
'ANTHROPIC_DEFAULT_HAIKU_MODEL',
'ANTHROPIC_AUTH_TOKEN', // Managed by API Key section
'ANTHROPIC_BASE_URL', // Base URL shown in profile header
]);
// Get non-managed env vars for display in "Additional Variables"