From 8b3c4189f1b033f293145ed46ea7258d5f67ed1c Mon Sep 17 00:00:00 2001 From: LTbinglingfeng Date: Wed, 28 Jan 2026 00:17:31 +0800 Subject: [PATCH] fix(providers): use /chat/completions for OpenAI test requests --- src/components/providers/utils.ts | 5 ++++- src/i18n/locales/en.json | 2 +- src/i18n/locales/zh-CN.json | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/providers/utils.ts b/src/components/providers/utils.ts index 7ba75a2..14edfeb 100644 --- a/src/components/providers/utils.ts +++ b/src/components/providers/utils.ts @@ -55,7 +55,10 @@ export const buildOpenAIChatCompletionsEndpoint = (baseUrl: string): string => { if (trimmed.endsWith('/chat/completions')) { return trimmed; } - return trimmed.endsWith('/v1') ? `${trimmed}/chat/completions` : `${trimmed}/v1/chat/completions`; + if (trimmed.endsWith('/v1')) { + return `${trimmed.slice(0, -3)}/chat/completions`; + } + return `${trimmed}/chat/completions`; }; // 根据 source (apiKey) 获取统计数据 - 与旧版逻辑一致 diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 02aad6e..5fc08e5 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -316,7 +316,7 @@ "openai_keys_count": "Keys Count", "openai_models_count": "Models Count", "openai_test_title": "Connection Test", - "openai_test_hint": "Send a /v1/chat/completions request with the current settings to verify availability.", + "openai_test_hint": "Send a /chat/completions request with the current settings to verify availability.", "openai_test_model_placeholder": "Model to test", "openai_test_action": "Run Test", "openai_test_running": "Sending test request...", diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json index 702685d..42906bd 100644 --- a/src/i18n/locales/zh-CN.json +++ b/src/i18n/locales/zh-CN.json @@ -316,7 +316,7 @@ "openai_keys_count": "密钥数量", "openai_models_count": "模型数量", "openai_test_title": "连通性测试", - "openai_test_hint": "使用当前配置向 /v1/chat/completions 请求,验证是否可用。", + "openai_test_hint": "使用当前配置向 /chat/completions 请求,验证是否可用。", "openai_test_model_placeholder": "选择或输入要测试的模型", "openai_test_action": "发送测试", "openai_test_running": "正在发送测试请求...",