mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-17 20:17:20 +00:00
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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user