diff --git a/backend/internal/handler/gateway_handler.go b/backend/internal/handler/gateway_handler.go index b46c86a3a9..dff922d109 100644 --- a/backend/internal/handler/gateway_handler.go +++ b/backend/internal/handler/gateway_handler.go @@ -164,9 +164,9 @@ func (h *GatewayHandler) Messages(c *gin.Context) { channelMapping = h.gatewayService.ResolveChannelMapping(c.Request.Context(), *apiKey.GroupID, reqModel) } - // 渠道模型限制检查:使用原始请求模型名,因为定价列表中注册的是用户请求的模型名 + // 渠道模型限制检查:先映射再判断,映射后的模型在定价列表中即放行 if apiKey.GroupID != nil { - if h.gatewayService.IsModelRestricted(c.Request.Context(), *apiKey.GroupID, reqModel) { + if h.gatewayService.IsModelRestricted(c.Request.Context(), *apiKey.GroupID, channelMapping.MappedModel) { h.errorResponse(c, http.StatusServiceUnavailable, "api_error", "No available accounts") return } diff --git a/backend/internal/handler/openai_gateway_handler.go b/backend/internal/handler/openai_gateway_handler.go index 7f68a56b96..c8b90e1480 100644 --- a/backend/internal/handler/openai_gateway_handler.go +++ b/backend/internal/handler/openai_gateway_handler.go @@ -191,10 +191,9 @@ func (h *OpenAIGatewayHandler) Responses(c *gin.Context) { channelMapping = h.gatewayService.ResolveChannelMapping(c.Request.Context(), *apiKey.GroupID, reqModel) } - // 渠道模型限制检查 + // 渠道模型限制检查:先映射再判断 if apiKey.GroupID != nil { - if h.gatewayService.IsModelRestricted(c.Request.Context(), *apiKey.GroupID, reqModel) { - h.errorResponse(c, http.StatusServiceUnavailable, "api_error", "No available accounts") + if h.gatewayService.IsModelRestricted(c.Request.Context(), *apiKey.GroupID, channelMapping.MappedModel) { return } } @@ -584,10 +583,9 @@ func (h *OpenAIGatewayHandler) Messages(c *gin.Context) { channelMappingMsg = h.gatewayService.ResolveChannelMapping(c.Request.Context(), *apiKey.GroupID, reqModel) } - // 渠道模型限制检查 + // 渠道模型限制检查:先映射再判断 if apiKey.GroupID != nil { - if h.gatewayService.IsModelRestricted(c.Request.Context(), *apiKey.GroupID, reqModel) { - h.anthropicErrorResponse(c, http.StatusServiceUnavailable, "api_error", "No available accounts") + if h.gatewayService.IsModelRestricted(c.Request.Context(), *apiKey.GroupID, channelMappingMsg.MappedModel) { return } } @@ -1165,9 +1163,9 @@ func (h *OpenAIGatewayHandler) ResponsesWebSocket(c *gin.Context) { channelMappingWS = h.gatewayService.ResolveChannelMapping(ctx, *apiKey.GroupID, reqModel) } - // 渠道模型限制检查 + // 渠道模型限制检查:先映射再判断 if apiKey.GroupID != nil { - if h.gatewayService.IsModelRestricted(ctx, *apiKey.GroupID, reqModel) { + if h.gatewayService.IsModelRestricted(ctx, *apiKey.GroupID, channelMappingWS.MappedModel) { closeOpenAIClientWS(wsConn, coderws.StatusPolicyViolation, "model not allowed") return } diff --git a/frontend/src/views/admin/ChannelsView.vue b/frontend/src/views/admin/ChannelsView.vue index c26a6fcfbc..6c57b26923 100644 --- a/frontend/src/views/admin/ChannelsView.vue +++ b/frontend/src/views/admin/ChannelsView.vue @@ -155,9 +155,9 @@ > {{ t('admin.channels.form.basicSettings', '基础设置') }} - + @@ -261,7 +255,7 @@