diff --git a/backend/internal/service/openai_gateway_service.go b/backend/internal/service/openai_gateway_service.go index c7d94882..45b4c69c 100644 --- a/backend/internal/service/openai_gateway_service.go +++ b/backend/internal/service/openai_gateway_service.go @@ -649,6 +649,12 @@ func (s *OpenAIGatewayService) Forward(ctx context.Context, c *gin.Context, acco bodyModified = true } } + + // Remove prompt_cache_retention (not supported by upstream OpenAI API) + if _, has := reqBody["prompt_cache_retention"]; has { + delete(reqBody, "prompt_cache_retention") + bodyModified = true + } } // Re-serialize body only if modified diff --git a/frontend/src/components/account/CreateAccountModal.vue b/frontend/src/components/account/CreateAccountModal.vue index c81de00e..05f328ac 100644 --- a/frontend/src/components/account/CreateAccountModal.vue +++ b/frontend/src/components/account/CreateAccountModal.vue @@ -2157,6 +2157,46 @@ const handleClose = () => { emit('close') } +// Helper function to create account with mixed channel warning handling +const doCreateAccount = async (payload: any, confirmMixedChannelRisk = false) => { + if (confirmMixedChannelRisk) { + payload.confirm_mixed_channel_risk = true + } + + submitting.value = true + try { + await adminAPI.accounts.create(payload) + appStore.showSuccess(t('admin.accounts.accountCreated')) + emit('created') + handleClose() + } catch (error: any) { + // Handle 409 mixed_channel_warning - show confirmation dialog + if (error.response?.status === 409 && error.response?.data?.error === 'mixed_channel_warning') { + const details = error.response.data.details || {} + const groupName = details.group_name || 'Unknown' + const currentPlatform = details.current_platform || 'Unknown' + const otherPlatform = details.other_platform || 'Unknown' + + const confirmMessage = t('admin.accounts.mixedChannelWarning', { + groupName, + currentPlatform, + otherPlatform + }) + + if (confirm(confirmMessage)) { + // Retry with confirmation flag + submitting.value = false + await doCreateAccount(payload, true) + return + } + } else { + appStore.showError(error.response?.data?.detail || t('admin.accounts.failedToCreate')) + } + } finally { + submitting.value = false + } +} + const handleSubmit = async () => { // For OAuth-based type, handle OAuth flow (goes to step 2) if (isOAuthFlow.value) { @@ -2213,21 +2253,11 @@ const handleSubmit = async () => { form.credentials = credentials - submitting.value = true - try { - await adminAPI.accounts.create({ - ...form, - group_ids: form.group_ids, - auto_pause_on_expired: autoPauseOnExpired.value - }) - appStore.showSuccess(t('admin.accounts.accountCreated')) - emit('created') - handleClose() - } catch (error: any) { - appStore.showError(error.response?.data?.detail || t('admin.accounts.failedToCreate')) - } finally { - submitting.value = false - } + await doCreateAccount({ + ...form, + group_ids: form.group_ids, + auto_pause_on_expired: autoPauseOnExpired.value + }) } const goBackToBasicInfo = () => { diff --git a/frontend/src/components/account/EditAccountModal.vue b/frontend/src/components/account/EditAccountModal.vue index d27364f1..63b54df0 100644 --- a/frontend/src/components/account/EditAccountModal.vue +++ b/frontend/src/components/account/EditAccountModal.vue @@ -8,7 +8,7 @@