feat: add configurable provider endpoint for codex-api accounts

Add providerEndpoint field (responses/completions/auto) to openai-responses
accounts, allowing admins to specify which API endpoint format the provider
supports. The relay service normalizes request paths based on this config:
- responses (default): routes all requests to /v1/responses
- completions: routes all requests to /v1/chat/completions
- auto: preserves the original request path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
X-Zero-L
2026-03-01 19:48:17 +08:00
parent 0871101f27
commit 0831739f4b
3 changed files with 60 additions and 4 deletions

View File

@@ -1692,6 +1692,24 @@
</p>
</div>
<div>
<label class="mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"
>Provider 端点类型</label
>
<select
v-model="form.providerEndpoint"
class="form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200"
>
<option value="responses">Responses推荐</option>
<option value="completions">Chat Completions</option>
<option value="auto">自动(保持原始路径)</option>
</select>
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
指定 Provider 支持的端点类型。Responses 会将所有请求路由到 /v1/responsesChat
Completions 路由到 /v1/chat/completions自动则保持客户端请求的原始路径
</p>
</div>
<!-- 限流时长字段 - 隐藏不显示使用默认值60 -->
<input v-model.number="form.rateLimitDuration" type="hidden" value="60" />
</div>
@@ -3440,6 +3458,24 @@
</p>
</div>
<div>
<label class="mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"
>Provider 端点类型</label
>
<select
v-model="form.providerEndpoint"
class="form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200"
>
<option value="responses">Responses推荐</option>
<option value="completions">Chat Completions</option>
<option value="auto">自动(保持原始路径)</option>
</select>
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
指定 Provider 支持的端点类型。Responses 路由到 /v1/responsesChat Completions
路由到 /v1/chat/completions自动则保持原始路径
</p>
</div>
<!-- 限流时长字段 - 隐藏不显示,保持原值 -->
<input v-model.number="form.rateLimitDuration" type="hidden" />
@@ -4272,6 +4308,7 @@ const form = ref({
endpointType: props.account?.endpointType || 'anthropic',
// OpenAI-Responses 特定字段
baseApi: props.account?.baseApi || '',
providerEndpoint: props.account?.providerEndpoint || 'responses',
// Gemini-API 特定字段
baseUrl: props.account?.baseUrl || 'https://generativelanguage.googleapis.com',
rateLimitDuration: props.account?.rateLimitDuration || 60,
@@ -5434,6 +5471,7 @@ const createAccount = async () => {
data.baseApi = form.value.baseApi
data.apiKey = form.value.apiKey
data.userAgent = form.value.userAgent || ''
data.providerEndpoint = form.value.providerEndpoint || 'responses'
data.priority = form.value.priority || 50
data.rateLimitDuration = 60 // 默认值60不从用户输入获取
data.dailyQuota = form.value.dailyQuota || 0
@@ -5784,6 +5822,7 @@ const updateAccount = async () => {
data.apiKey = form.value.apiKey
}
data.userAgent = form.value.userAgent || ''
data.providerEndpoint = form.value.providerEndpoint || 'responses'
data.priority = form.value.priority || 50
// 编辑时不上传 rateLimitDuration保持原值
data.dailyQuota = form.value.dailyQuota || 0
@@ -6406,6 +6445,7 @@ watch(
deploymentName: newAccount.deploymentName || '',
// OpenAI-Responses 特定字段
baseApi: newAccount.baseApi || '',
providerEndpoint: newAccount.providerEndpoint || 'responses',
// Gemini-API 特定字段
baseUrl: newAccount.baseUrl || 'https://generativelanguage.googleapis.com',
// 额度管理字段