@@ -3327,6 +3332,8 @@ class CLIProxyManager {
${config['base-url'] ? `
${i18n.t('common.base_url')}: ${this.escapeHtml(config['base-url'])}
` : ''}
${config['proxy-url'] ? `
${i18n.t('common.proxy_url')}: ${this.escapeHtml(config['proxy-url'])}
` : ''}
${this.renderHeaderBadges(config.headers)}
+ ${modelsCountHtml}
+ ${modelsBadgesHtml}
${i18n.t('stats.success')}: ${keyStats.success}
@@ -3373,6 +3380,12 @@ class CLIProxyManager {
+
@@ -3381,6 +3394,7 @@ class CLIProxyManager {
modal.style.display = 'block';
this.populateHeaderFields('new-claude-headers-wrapper');
+ this.populateModelFields('new-claude-models-wrapper');
}
// 添加Claude密钥
@@ -3389,6 +3403,7 @@ class CLIProxyManager {
const baseUrl = document.getElementById('new-claude-url').value.trim();
const proxyUrl = document.getElementById('new-claude-proxy').value.trim();
const headers = this.collectHeaderInputs('new-claude-headers-wrapper');
+ const models = this.collectModelInputs('new-claude-models-wrapper');
if (!apiKey) {
this.showNotification(i18n.t('notification.field_required'), 'error');
@@ -3407,6 +3422,9 @@ class CLIProxyManager {
newConfig['proxy-url'] = proxyUrl;
}
this.applyHeadersToConfig(newConfig, headers);
+ if (models.length) {
+ newConfig.models = models;
+ }
currentKeys.push(newConfig);
@@ -3449,6 +3467,12 @@ class CLIProxyManager {
+
@@ -3457,6 +3481,7 @@ class CLIProxyManager {
modal.style.display = 'block';
this.populateHeaderFields('edit-claude-headers-wrapper', config.headers || null);
+ this.populateModelFields('edit-claude-models-wrapper', Array.isArray(config.models) ? config.models : []);
}
// 更新Claude密钥
@@ -3465,6 +3490,7 @@ class CLIProxyManager {
const baseUrl = document.getElementById('edit-claude-url').value.trim();
const proxyUrl = document.getElementById('edit-claude-proxy').value.trim();
const headers = this.collectHeaderInputs('edit-claude-headers-wrapper');
+ const models = this.collectModelInputs('edit-claude-models-wrapper');
if (!apiKey) {
this.showNotification(i18n.t('notification.field_required'), 'error');
@@ -3480,6 +3506,9 @@ class CLIProxyManager {
newConfig['proxy-url'] = proxyUrl;
}
this.applyHeadersToConfig(newConfig, headers);
+ if (models.length) {
+ newConfig.models = models;
+ }
await this.makeRequest('/claude-api-key', {
method: 'PATCH',
@@ -3595,7 +3624,7 @@ class CLIProxyManager {
${this.renderHeaderBadges(item.headers)}
${i18n.t('ai_providers.openai_keys_count')}: ${apiKeyEntries.length}
${i18n.t('ai_providers.openai_models_count')}: ${models.length}
- ${this.renderOpenAIModelBadges(models)}
+ ${this.renderModelBadges(models)}
${i18n.t('stats.success')}: ${totalSuccess}
@@ -5888,8 +5917,8 @@ class CLIProxyManager {
row.className = 'model-input-row';
row.innerHTML = `
-
-
+
+
`;
@@ -5942,7 +5971,7 @@ class CLIProxyManager {
return models;
}
- renderOpenAIModelBadges(models) {
+ renderModelBadges(models) {
if (!models || models.length === 0) {
return '';
}
diff --git a/i18n.js b/i18n.js
index 2e7096a..d185495 100644
--- a/i18n.js
+++ b/i18n.js
@@ -46,6 +46,8 @@ const i18n = {
'common.custom_headers_add': '添加请求头',
'common.custom_headers_key_placeholder': 'Header 名称,例如 X-Custom-Header',
'common.custom_headers_value_placeholder': 'Header 值',
+ 'common.model_name_placeholder': '模型名称,例如 claude-3-5-sonnet-20241022',
+ 'common.model_alias_placeholder': '模型别名 (可选)',
// 页面标题
'title.main': 'CLI Proxy API Management Center',
@@ -184,6 +186,10 @@ const i18n = {
'ai_providers.claude_edit_modal_url_label': 'Base URL (可选):',
'ai_providers.claude_edit_modal_proxy_label': '代理 URL (可选):',
'ai_providers.claude_delete_confirm': '确定要删除这个Claude配置吗?',
+ 'ai_providers.claude_models_label': '自定义模型 (可选):',
+ 'ai_providers.claude_models_hint': '为空表示使用全部模型;可填写 name[, alias] 以限制或重命名模型。',
+ 'ai_providers.claude_models_add_btn': '添加模型',
+ 'ai_providers.claude_models_count': '模型数量',
'ai_providers.openai_title': 'OpenAI 兼容提供商',
'ai_providers.openai_add_button': '添加提供商',
@@ -533,6 +539,8 @@ const i18n = {
'common.custom_headers_add': 'Add Header',
'common.custom_headers_key_placeholder': 'Header name, e.g. X-Custom-Header',
'common.custom_headers_value_placeholder': 'Header value',
+ 'common.model_name_placeholder': 'Model name, e.g. claude-3-5-sonnet-20241022',
+ 'common.model_alias_placeholder': 'Model alias (optional)',
// Page titles
'title.main': 'CLI Proxy API Management Center',
@@ -671,6 +679,10 @@ const i18n = {
'ai_providers.claude_edit_modal_url_label': 'Base URL (Optional):',
'ai_providers.claude_edit_modal_proxy_label': 'Proxy URL (Optional):',
'ai_providers.claude_delete_confirm': 'Are you sure you want to delete this Claude configuration?',
+ 'ai_providers.claude_models_label': 'Custom Models (Optional):',
+ 'ai_providers.claude_models_hint': 'Leave empty to allow all models, or add name[, alias] entries to limit/alias them.',
+ 'ai_providers.claude_models_add_btn': 'Add Model',
+ 'ai_providers.claude_models_count': 'Models Count',
'ai_providers.openai_title': 'OpenAI Compatible Providers',
'ai_providers.openai_add_button': 'Add Provider',