zijiren 8 месяцев назад
Родитель
Сommit
041a3a751b
50 измененных файлов с 1052 добавлено и 402 удалено
  1. 3 16
      core/controller/channel.go
  2. 34 36
      core/controller/import.go
  3. 93 5
      core/controller/model.go
  4. 1 6
      core/controller/relay-controller.go
  5. 276 44
      core/docs/docs.go
  6. 276 44
      core/docs/swagger.json
  7. 204 26
      core/docs/swagger.yaml
  8. 1 3
      core/middleware/auth.go
  9. 10 5
      core/model/cache.go
  10. 1 1
      core/model/channel.go
  11. 11 11
      core/model/channeltest.go
  12. 94 0
      core/model/chtype.go
  13. 0 4
      core/relay/adaptor/ai360/adaptor.go
  14. 0 4
      core/relay/adaptor/ali/adaptor.go
  15. 0 4
      core/relay/adaptor/anthropic/adaptor.go
  16. 0 4
      core/relay/adaptor/aws/adaptor.go
  17. 0 4
      core/relay/adaptor/azure/main.go
  18. 0 4
      core/relay/adaptor/baichuan/adaptor.go
  19. 0 4
      core/relay/adaptor/baidu/adaptor.go
  20. 0 4
      core/relay/adaptor/baiduv2/adaptor.go
  21. 0 4
      core/relay/adaptor/cloudflare/adaptor.go
  22. 0 4
      core/relay/adaptor/cohere/adaptor.go
  23. 0 4
      core/relay/adaptor/coze/adaptor.go
  24. 0 4
      core/relay/adaptor/deepseek/adaptor.go
  25. 0 4
      core/relay/adaptor/doc2x/adaptor.go
  26. 0 4
      core/relay/adaptor/doubao/main.go
  27. 0 4
      core/relay/adaptor/doubaoaudio/main.go
  28. 0 4
      core/relay/adaptor/gemini/adaptor.go
  29. 0 4
      core/relay/adaptor/geminiopenai/adaptor.go
  30. 0 4
      core/relay/adaptor/groq/adaptor.go
  31. 0 1
      core/relay/adaptor/interface.go
  32. 0 4
      core/relay/adaptor/jina/adaptor.go
  33. 0 4
      core/relay/adaptor/lingyiwanwu/adaptor.go
  34. 0 4
      core/relay/adaptor/minimax/adaptor.go
  35. 0 4
      core/relay/adaptor/mistral/adaptor.go
  36. 0 4
      core/relay/adaptor/moonshot/adaptor.go
  37. 0 4
      core/relay/adaptor/novita/adaptor.go
  38. 0 4
      core/relay/adaptor/ollama/adaptor.go
  39. 0 4
      core/relay/adaptor/openai/adaptor.go
  40. 0 4
      core/relay/adaptor/openrouter/adaptor.go
  41. 0 4
      core/relay/adaptor/siliconflow/adaptor.go
  42. 0 4
      core/relay/adaptor/stepfun/adaptor.go
  43. 0 4
      core/relay/adaptor/tencent/adaptor.go
  44. 0 6
      core/relay/adaptor/vertexai/adaptor.go
  45. 0 4
      core/relay/adaptor/xai/adaptor.go
  46. 0 4
      core/relay/adaptor/xunfei/adaptor.go
  47. 0 4
      core/relay/adaptor/zhipu/adaptor.go
  48. 40 53
      core/relay/channeltype/define.go
  49. 5 12
      core/relay/meta/meta.go
  50. 3 1
      core/router/api.go

+ 3 - 16
core/controller/channel.go

@@ -17,19 +17,6 @@ import (
 	log "github.com/sirupsen/logrus"
 )
 
-// ChannelTypeNames godoc
-//
-//	@Summary		Get all channel type names
-//	@Description	Returns a list of all available channel type names
-//	@Tags			channels
-//	@Produce		json
-//	@Security		ApiKeyAuth
-//	@Success		200	{object}	middleware.APIResponse{data=map[int]string}
-//	@Router			/api/channels/type_names [get]
-func ChannelTypeNames(c *gin.Context) {
-	middleware.SuccessResponse(c, channeltype.ChannelNames)
-}
-
 // ChannelTypeMetas godoc
 //
 //	@Summary		Get channel type metadata
@@ -202,7 +189,7 @@ type AddChannelRequest struct {
 	Key          string               `json:"key"`
 	BaseURL      string               `json:"base_url"`
 	Models       []string             `json:"models"`
-	Type         int                  `json:"type"`
+	Type         model.ChannelType    `json:"type"`
 	Priority     int32                `json:"priority"`
 	Status       int                  `json:"status"`
 	Sets         []string             `json:"sets"`
@@ -218,9 +205,9 @@ func (r *AddChannelRequest) ToChannel() (*model.Channel, error) {
 		if err != nil {
 			keyHelp := validator.KeyHelp()
 			if keyHelp == "" {
-				return nil, fmt.Errorf("%s [%s(%d)] invalid key: %w", r.Name, channeltype.ChannelNames[r.Type], r.Type, err)
+				return nil, fmt.Errorf("%s [%s(%d)] invalid key: %w", r.Name, r.Type.String(), r.Type, err)
 			}
-			return nil, fmt.Errorf("%s [%s(%d)] invalid key: %w, %s", r.Name, channeltype.ChannelNames[r.Type], r.Type, err, keyHelp)
+			return nil, fmt.Errorf("%s [%s(%d)] invalid key: %w, %s", r.Name, r.Type.String(), r.Type, err, keyHelp)
 		}
 	}
 	return &model.Channel{

+ 34 - 36
core/controller/import.go

@@ -92,41 +92,39 @@ const (
 	OneAPIGeminiOpenAICompatible
 )
 
-// relay/channeltype/define.go
-
-var OneAPIChannelType2AIProxyMap = map[int]int{
-	OneAPIOpenAI:                 1,
-	OneAPIAzure:                  3,
-	OneAPIAnthropic:              14,
-	OneAPIBaidu:                  15,
-	OneAPIZhipu:                  16,
-	OneAPIAli:                    17,
-	OneAPIAI360:                  19,
-	OneAPIOpenRouter:             20,
-	OneAPITencent:                23,
-	OneAPIGemini:                 24,
-	OneAPIMoonshot:               25,
-	OneAPIBaichuan:               26,
-	OneAPIMinimax:                27,
-	OneAPIMistral:                28,
-	OneAPIGroq:                   29,
-	OneAPIOllama:                 30,
-	OneAPILingYiWanWu:            31,
-	OneAPIStepFun:                32,
-	OneAPIAwsClaude:              33,
-	OneAPICoze:                   34,
-	OneAPICohere:                 35,
-	OneAPIDeepSeek:               36,
-	OneAPICloudflare:             37,
-	OneAPIDoubao:                 40,
-	OneAPINovita:                 41,
-	OneAPIVertextAI:              42,
-	OneAPISiliconFlow:            43,
-	OneAPIBaiduV2:                13,
-	OneAPIXunfeiV2:               18,
-	OneAPIAliBailian:             17,
-	OneAPIGeminiOpenAICompatible: 12,
-	OneAPIXAI:                    45,
+var OneAPIChannelType2AIProxyMap = map[int]model.ChannelType{
+	OneAPIOpenAI:                 model.ChannelTypeOpenAI,
+	OneAPIAzure:                  model.ChannelTypeAzure,
+	OneAPIAnthropic:              model.ChannelTypeAnthropic,
+	OneAPIBaidu:                  model.ChannelTypeBaidu,
+	OneAPIZhipu:                  model.ChannelTypeZhipu,
+	OneAPIAli:                    model.ChannelTypeAli,
+	OneAPIAI360:                  model.ChannelTypeAI360,
+	OneAPIOpenRouter:             model.ChannelTypeOpenRouter,
+	OneAPITencent:                model.ChannelTypeTencent,
+	OneAPIGemini:                 model.ChannelTypeGoogleGemini,
+	OneAPIMoonshot:               model.ChannelTypeMoonshot,
+	OneAPIBaichuan:               model.ChannelTypeBaichuan,
+	OneAPIMinimax:                model.ChannelTypeMinimax,
+	OneAPIMistral:                model.ChannelTypeMistral,
+	OneAPIGroq:                   model.ChannelTypeGroq,
+	OneAPIOllama:                 model.ChannelTypeOllama,
+	OneAPILingYiWanWu:            model.ChannelTypeLingyiwanwu,
+	OneAPIStepFun:                model.ChannelTypeStepfun,
+	OneAPIAwsClaude:              model.ChannelTypeAWS,
+	OneAPICoze:                   model.ChannelTypeCoze,
+	OneAPICohere:                 model.ChannelTypeCohere,
+	OneAPIDeepSeek:               model.ChannelTypeDeepseek,
+	OneAPICloudflare:             model.ChannelTypeCloudflare,
+	OneAPIDoubao:                 model.ChannelTypeDoubao,
+	OneAPINovita:                 model.ChannelTypeNovita,
+	OneAPIVertextAI:              model.ChannelTypeVertexAI,
+	OneAPISiliconFlow:            model.ChannelTypeSiliconflow,
+	OneAPIBaiduV2:                model.ChannelTypeBaiduV2,
+	OneAPIXunfeiV2:               model.ChannelTypeXunfei,
+	OneAPIAliBailian:             model.ChannelTypeAli,
+	OneAPIGeminiOpenAICompatible: model.ChannelTypeGoogleGeminiOpenAI,
+	OneAPIXAI:                    model.ChannelTypeXAI,
 }
 
 type ImportChannelFromOneAPIRequest struct {
@@ -135,7 +133,7 @@ type ImportChannelFromOneAPIRequest struct {
 
 func AddOneAPIChannel(ch OneAPIChannel) error {
 	add := AddChannelRequest{
-		Type:         ch.Type,
+		Type:         model.ChannelType(ch.Type),
 		Name:         ch.Name,
 		Key:          ch.Key,
 		BaseURL:      ch.BaseURL,

+ 93 - 5
core/controller/model.go

@@ -62,7 +62,7 @@ func SortBuiltinModelConfigsFunc(i, j *BuiltinModelConfig) int {
 var (
 	builtinModels             []*BuiltinModelConfig
 	builtinModelsMap          map[string]*OpenAIModels
-	builtinChannelType2Models map[int][]*BuiltinModelConfig
+	builtinChannelType2Models map[model.ChannelType][]*BuiltinModelConfig
 )
 
 var permission = []OpenAIModelPermission{
@@ -83,7 +83,7 @@ var permission = []OpenAIModelPermission{
 }
 
 func init() {
-	builtinChannelType2Models = make(map[int][]*BuiltinModelConfig)
+	builtinChannelType2Models = make(map[model.ChannelType][]*BuiltinModelConfig)
 	builtinModelsMap = make(map[string]*OpenAIModels)
 	// https://platform.openai.com/docs/models/model-endpoint-compatibility
 	for i, adaptor := range channeltype.ChannelAdaptor {
@@ -91,7 +91,7 @@ func init() {
 		builtinChannelType2Models[i] = make([]*BuiltinModelConfig, len(modelNames))
 		for idx, _model := range modelNames {
 			if _model.Owner == "" {
-				_model.Owner = model.ModelOwner(adaptor.GetChannelName())
+				_model.Owner = model.ModelOwner(i.String())
 			}
 			if v, ok := builtinModelsMap[_model.Model]; !ok {
 				builtinModelsMap[_model.Model] = &OpenAIModels{
@@ -152,7 +152,7 @@ func ChannelBuiltinModels(c *gin.Context) {
 //	@Tags			model
 //	@Produce		json
 //	@Security		ApiKeyAuth
-//	@Param			type	path		string	true	"Channel type"
+//	@Param			type	path		model.ChannelType	true	"Channel type"
 //	@Success		200		{object}	middleware.APIResponse{data=[]BuiltinModelConfig}
 //	@Router			/api/models/builtin/channel/{type} [get]
 func ChannelBuiltinModelsByType(c *gin.Context) {
@@ -166,7 +166,7 @@ func ChannelBuiltinModelsByType(c *gin.Context) {
 		middleware.ErrorResponse(c, http.StatusOK, "invalid type")
 		return
 	}
-	middleware.SuccessResponse(c, builtinChannelType2Models[channelTypeInt])
+	middleware.SuccessResponse(c, builtinChannelType2Models[model.ChannelType(channelTypeInt)])
 }
 
 // ChannelDefaultModelsAndMapping godoc
@@ -224,3 +224,91 @@ func ChannelDefaultModelsAndMappingByType(c *gin.Context) {
 func EnabledModels(c *gin.Context) {
 	middleware.SuccessResponse(c, model.LoadModelCaches().EnabledModelConfigsBySet)
 }
+
+// EnabledModelsSet godoc
+//
+//	@Summary		Get enabled models by set
+//	@Description	Returns a list of enabled models by set
+//	@Tags			model
+//	@Produce		json
+//	@Security		ApiKeyAuth
+//	@Param			set	path		string	true	"Models set"
+//	@Success		200	{object}	middleware.APIResponse{data=[]model.ModelConfig}
+//	@Router			/api/models/enabled/{set} [get]
+func EnabledModelsSet(c *gin.Context) {
+	set := c.Param("set")
+	if set == "" {
+		middleware.ErrorResponse(c, http.StatusOK, "set is required")
+		return
+	}
+	middleware.SuccessResponse(c, model.LoadModelCaches().EnabledModelConfigsBySet[set])
+}
+
+type EnabledModelChannel struct {
+	ID   int               `json:"id"`
+	Type model.ChannelType `json:"type"`
+	Name string            `json:"name"`
+}
+
+func newEnabledModelChannel(ch *model.Channel) EnabledModelChannel {
+	return EnabledModelChannel{
+		ID:   ch.ID,
+		Type: ch.Type,
+		Name: ch.Name,
+	}
+}
+
+// EnabledModelChannels godoc
+//
+//	@Summary		Get enabled models and channels
+//	@Description	Returns a list of enabled models
+//	@Tags			model
+//	@Produce		json
+//	@Security		ApiKeyAuth
+//	@Success		200	{object}	middleware.APIResponse{data=map[string]map[string][]EnabledModelChannel}
+//	@Router			/api/models/channel [get]
+func EnabledModelChannels(c *gin.Context) {
+	raw := model.LoadModelCaches().EnabledModel2ChannelsBySet
+	result := make(map[string]map[string][]EnabledModelChannel)
+
+	for set, modelChannels := range raw {
+		result[set] = make(map[string][]EnabledModelChannel)
+		for model, channels := range modelChannels {
+			chs := make([]EnabledModelChannel, len(channels))
+			for i, channel := range channels {
+				chs[i] = newEnabledModelChannel(channel)
+			}
+			result[set][model] = chs
+		}
+	}
+
+	middleware.SuccessResponse(c, result)
+}
+
+// EnabledModelChannelsSet godoc
+//
+//	@Summary		Get enabled models and channels by set
+//	@Description	Returns a list of enabled models and channels by set
+//	@Tags			model
+//	@Produce		json
+//	@Security		ApiKeyAuth
+//	@Param			set	path		string	true	"Models set"
+//	@Success		200	{object}	middleware.APIResponse{data=map[string][]EnabledModelChannel}
+//	@Router			/api/models/channel/{set} [get]
+func EnabledModelChannelsSet(c *gin.Context) {
+	set := c.Param("set")
+	if set == "" {
+		middleware.ErrorResponse(c, http.StatusOK, "set is required")
+		return
+	}
+	raw := model.LoadModelCaches().EnabledModel2ChannelsBySet[set]
+	result := make(map[string][]EnabledModelChannel, len(raw))
+	for model, channels := range raw {
+		chs := make([]EnabledModelChannel, len(channels))
+		for i, channel := range channels {
+			chs[i] = newEnabledModelChannel(channel)
+		}
+		result[model] = chs
+	}
+	middleware.SuccessResponse(c, result)
+}

+ 1 - 6
core/controller/relay-controller.go

@@ -21,7 +21,6 @@ import (
 	"github.com/labring/aiproxy/core/middleware"
 	"github.com/labring/aiproxy/core/model"
 	"github.com/labring/aiproxy/core/monitor"
-	"github.com/labring/aiproxy/core/relay/channeltype"
 	"github.com/labring/aiproxy/core/relay/controller"
 	"github.com/labring/aiproxy/core/relay/meta"
 	"github.com/labring/aiproxy/core/relay/mode"
@@ -143,7 +142,7 @@ func notifyChannelIssue(meta *meta.Meta, issueType string, titleSuffix string, e
 		"channel: %s (type: %d, type name: %s, id: %d)\nmodel: %s\nmode: %s\nstatus code: %d\ndetail: %s\nrequest id: %s",
 		meta.Channel.Name,
 		meta.Channel.Type,
-		meta.Channel.TypeName,
+		meta.Channel.Type.String(),
 		meta.Channel.ID,
 		meta.OriginModel,
 		meta.Mode,
@@ -287,10 +286,6 @@ func NewRelay(mode mode.Mode) func(c *gin.Context) {
 }
 
 func NewMetaByContext(c *gin.Context, channel *model.Channel, mode mode.Mode, opts ...meta.Option) *meta.Meta {
-	channelTypeName := channeltype.GetChannelName(channel.Type)
-	if channelTypeName != "" {
-		opts = append(opts, meta.WithChannelTypeName(channelTypeName))
-	}
 	return middleware.NewMetaByContext(c, channel, mode, opts...)
 }
 

+ 276 - 44
core/docs/docs.go

@@ -921,46 +921,6 @@ const docTemplate = `{
                 }
             }
         },
-        "/api/channels/type_names": {
-            "get": {
-                "security": [
-                    {
-                        "ApiKeyAuth": []
-                    }
-                ],
-                "description": "Returns a list of all available channel type names",
-                "produces": [
-                    "application/json"
-                ],
-                "tags": [
-                    "channels"
-                ],
-                "summary": "Get all channel type names",
-                "responses": {
-                    "200": {
-                        "description": "OK",
-                        "schema": {
-                            "allOf": [
-                                {
-                                    "$ref": "#/definitions/middleware.APIResponse"
-                                },
-                                {
-                                    "type": "object",
-                                    "properties": {
-                                        "data": {
-                                            "type": "object",
-                                            "additionalProperties": {
-                                                "type": "string"
-                                            }
-                                        }
-                                    }
-                                }
-                            ]
-                        }
-                    }
-                }
-            }
-        },
         "/api/dashboard": {
             "get": {
                 "security": [
@@ -4450,7 +4410,43 @@ const docTemplate = `{
                 "summary": "Get channel builtin models by type",
                 "parameters": [
                     {
-                        "type": "string",
+                        "enum": [
+                            1,
+                            3,
+                            12,
+                            13,
+                            14,
+                            15,
+                            16,
+                            17,
+                            18,
+                            19,
+                            20,
+                            23,
+                            24,
+                            25,
+                            26,
+                            27,
+                            28,
+                            29,
+                            30,
+                            31,
+                            32,
+                            33,
+                            34,
+                            35,
+                            36,
+                            37,
+                            40,
+                            41,
+                            42,
+                            43,
+                            44,
+                            45,
+                            46,
+                            47
+                        ],
+                        "type": "integer",
                         "description": "Channel type",
                         "name": "type",
                         "in": "path",
@@ -4482,6 +4478,104 @@ const docTemplate = `{
                 }
             }
         },
+        "/api/models/channel": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "Returns a list of enabled models",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "model"
+                ],
+                "summary": "Get enabled models and channels",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/middleware.APIResponse"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "type": "object",
+                                            "additionalProperties": {
+                                                "type": "object",
+                                                "additionalProperties": {
+                                                    "type": "array",
+                                                    "items": {
+                                                        "$ref": "#/definitions/controller.EnabledModelChannel"
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
+        "/api/models/channel/{set}": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "Returns a list of enabled models and channels by set",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "model"
+                ],
+                "summary": "Get enabled models and channels by set",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Models set",
+                        "name": "set",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/middleware.APIResponse"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "type": "object",
+                                            "additionalProperties": {
+                                                "type": "array",
+                                                "items": {
+                                                    "$ref": "#/definitions/controller.EnabledModelChannel"
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
         "/api/models/default": {
             "get": {
                 "security": [
@@ -4652,6 +4746,55 @@ const docTemplate = `{
                 }
             }
         },
+        "/api/models/enabled/{set}": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "Returns a list of enabled models by set",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "model"
+                ],
+                "summary": "Get enabled models by set",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Models set",
+                        "name": "set",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/middleware.APIResponse"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "type": "array",
+                                            "items": {
+                                                "$ref": "#/definitions/model.ModelConfig"
+                                            }
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
         "/api/monitor": {
             "get": {
                 "security": [
@@ -7141,7 +7284,7 @@ const docTemplate = `{
                     "type": "integer"
                 },
                 "type": {
-                    "type": "integer"
+                    "$ref": "#/definitions/model.ChannelType"
                 }
             }
         },
@@ -7250,6 +7393,20 @@ const docTemplate = `{
                 }
             }
         },
+        "controller.EnabledModelChannel": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                },
+                "type": {
+                    "$ref": "#/definitions/model.ChannelType"
+                }
+            }
+        },
         "controller.GetModelConfigsByModelsContainsRequest": {
             "type": "object",
             "properties": {
@@ -7791,7 +7948,7 @@ const docTemplate = `{
                     "type": "integer"
                 },
                 "type": {
-                    "type": "integer"
+                    "$ref": "#/definitions/model.ChannelType"
                 },
                 "used_amount": {
                     "type": "number"
@@ -7819,7 +7976,7 @@ const docTemplate = `{
                     "type": "string"
                 },
                 "channel_type": {
-                    "type": "integer"
+                    "$ref": "#/definitions/model.ChannelType"
                 },
                 "code": {
                     "type": "integer"
@@ -7844,6 +8001,81 @@ const docTemplate = `{
                 }
             }
         },
+        "model.ChannelType": {
+            "type": "integer",
+            "enum": [
+                1,
+                3,
+                12,
+                13,
+                14,
+                15,
+                16,
+                17,
+                18,
+                19,
+                20,
+                23,
+                24,
+                25,
+                26,
+                27,
+                28,
+                29,
+                30,
+                31,
+                32,
+                33,
+                34,
+                35,
+                36,
+                37,
+                40,
+                41,
+                42,
+                43,
+                44,
+                45,
+                46,
+                47
+            ],
+            "x-enum-varnames": [
+                "ChannelTypeOpenAI",
+                "ChannelTypeAzure",
+                "ChannelTypeGoogleGeminiOpenAI",
+                "ChannelTypeBaiduV2",
+                "ChannelTypeAnthropic",
+                "ChannelTypeBaidu",
+                "ChannelTypeZhipu",
+                "ChannelTypeAli",
+                "ChannelTypeXunfei",
+                "ChannelTypeAI360",
+                "ChannelTypeOpenRouter",
+                "ChannelTypeTencent",
+                "ChannelTypeGoogleGemini",
+                "ChannelTypeMoonshot",
+                "ChannelTypeBaichuan",
+                "ChannelTypeMinimax",
+                "ChannelTypeMistral",
+                "ChannelTypeGroq",
+                "ChannelTypeOllama",
+                "ChannelTypeLingyiwanwu",
+                "ChannelTypeStepfun",
+                "ChannelTypeAWS",
+                "ChannelTypeCoze",
+                "ChannelTypeCohere",
+                "ChannelTypeDeepseek",
+                "ChannelTypeCloudflare",
+                "ChannelTypeDoubao",
+                "ChannelTypeNovita",
+                "ChannelTypeVertexAI",
+                "ChannelTypeSiliconflow",
+                "ChannelTypeDoubaoAudio",
+                "ChannelTypeXAI",
+                "ChannelTypeDoc2x",
+                "ChannelTypeJina"
+            ]
+        },
         "model.ChartData": {
             "type": "object",
             "properties": {

+ 276 - 44
core/docs/swagger.json

@@ -912,46 +912,6 @@
                 }
             }
         },
-        "/api/channels/type_names": {
-            "get": {
-                "security": [
-                    {
-                        "ApiKeyAuth": []
-                    }
-                ],
-                "description": "Returns a list of all available channel type names",
-                "produces": [
-                    "application/json"
-                ],
-                "tags": [
-                    "channels"
-                ],
-                "summary": "Get all channel type names",
-                "responses": {
-                    "200": {
-                        "description": "OK",
-                        "schema": {
-                            "allOf": [
-                                {
-                                    "$ref": "#/definitions/middleware.APIResponse"
-                                },
-                                {
-                                    "type": "object",
-                                    "properties": {
-                                        "data": {
-                                            "type": "object",
-                                            "additionalProperties": {
-                                                "type": "string"
-                                            }
-                                        }
-                                    }
-                                }
-                            ]
-                        }
-                    }
-                }
-            }
-        },
         "/api/dashboard": {
             "get": {
                 "security": [
@@ -4441,7 +4401,43 @@
                 "summary": "Get channel builtin models by type",
                 "parameters": [
                     {
-                        "type": "string",
+                        "enum": [
+                            1,
+                            3,
+                            12,
+                            13,
+                            14,
+                            15,
+                            16,
+                            17,
+                            18,
+                            19,
+                            20,
+                            23,
+                            24,
+                            25,
+                            26,
+                            27,
+                            28,
+                            29,
+                            30,
+                            31,
+                            32,
+                            33,
+                            34,
+                            35,
+                            36,
+                            37,
+                            40,
+                            41,
+                            42,
+                            43,
+                            44,
+                            45,
+                            46,
+                            47
+                        ],
+                        "type": "integer",
                         "description": "Channel type",
                         "name": "type",
                         "in": "path",
@@ -4473,6 +4469,104 @@
                 }
             }
         },
+        "/api/models/channel": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "Returns a list of enabled models",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "model"
+                ],
+                "summary": "Get enabled models and channels",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/middleware.APIResponse"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "type": "object",
+                                            "additionalProperties": {
+                                                "type": "object",
+                                                "additionalProperties": {
+                                                    "type": "array",
+                                                    "items": {
+                                                        "$ref": "#/definitions/controller.EnabledModelChannel"
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
+        "/api/models/channel/{set}": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "Returns a list of enabled models and channels by set",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "model"
+                ],
+                "summary": "Get enabled models and channels by set",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Models set",
+                        "name": "set",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/middleware.APIResponse"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "type": "object",
+                                            "additionalProperties": {
+                                                "type": "array",
+                                                "items": {
+                                                    "$ref": "#/definitions/controller.EnabledModelChannel"
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
         "/api/models/default": {
             "get": {
                 "security": [
@@ -4643,6 +4737,55 @@
                 }
             }
         },
+        "/api/models/enabled/{set}": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "Returns a list of enabled models by set",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "model"
+                ],
+                "summary": "Get enabled models by set",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Models set",
+                        "name": "set",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/middleware.APIResponse"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "type": "array",
+                                            "items": {
+                                                "$ref": "#/definitions/model.ModelConfig"
+                                            }
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
         "/api/monitor": {
             "get": {
                 "security": [
@@ -7132,7 +7275,7 @@
                     "type": "integer"
                 },
                 "type": {
-                    "type": "integer"
+                    "$ref": "#/definitions/model.ChannelType"
                 }
             }
         },
@@ -7241,6 +7384,20 @@
                 }
             }
         },
+        "controller.EnabledModelChannel": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                },
+                "type": {
+                    "$ref": "#/definitions/model.ChannelType"
+                }
+            }
+        },
         "controller.GetModelConfigsByModelsContainsRequest": {
             "type": "object",
             "properties": {
@@ -7782,7 +7939,7 @@
                     "type": "integer"
                 },
                 "type": {
-                    "type": "integer"
+                    "$ref": "#/definitions/model.ChannelType"
                 },
                 "used_amount": {
                     "type": "number"
@@ -7810,7 +7967,7 @@
                     "type": "string"
                 },
                 "channel_type": {
-                    "type": "integer"
+                    "$ref": "#/definitions/model.ChannelType"
                 },
                 "code": {
                     "type": "integer"
@@ -7835,6 +7992,81 @@
                 }
             }
         },
+        "model.ChannelType": {
+            "type": "integer",
+            "enum": [
+                1,
+                3,
+                12,
+                13,
+                14,
+                15,
+                16,
+                17,
+                18,
+                19,
+                20,
+                23,
+                24,
+                25,
+                26,
+                27,
+                28,
+                29,
+                30,
+                31,
+                32,
+                33,
+                34,
+                35,
+                36,
+                37,
+                40,
+                41,
+                42,
+                43,
+                44,
+                45,
+                46,
+                47
+            ],
+            "x-enum-varnames": [
+                "ChannelTypeOpenAI",
+                "ChannelTypeAzure",
+                "ChannelTypeGoogleGeminiOpenAI",
+                "ChannelTypeBaiduV2",
+                "ChannelTypeAnthropic",
+                "ChannelTypeBaidu",
+                "ChannelTypeZhipu",
+                "ChannelTypeAli",
+                "ChannelTypeXunfei",
+                "ChannelTypeAI360",
+                "ChannelTypeOpenRouter",
+                "ChannelTypeTencent",
+                "ChannelTypeGoogleGemini",
+                "ChannelTypeMoonshot",
+                "ChannelTypeBaichuan",
+                "ChannelTypeMinimax",
+                "ChannelTypeMistral",
+                "ChannelTypeGroq",
+                "ChannelTypeOllama",
+                "ChannelTypeLingyiwanwu",
+                "ChannelTypeStepfun",
+                "ChannelTypeAWS",
+                "ChannelTypeCoze",
+                "ChannelTypeCohere",
+                "ChannelTypeDeepseek",
+                "ChannelTypeCloudflare",
+                "ChannelTypeDoubao",
+                "ChannelTypeNovita",
+                "ChannelTypeVertexAI",
+                "ChannelTypeSiliconflow",
+                "ChannelTypeDoubaoAudio",
+                "ChannelTypeXAI",
+                "ChannelTypeDoc2x",
+                "ChannelTypeJina"
+            ]
+        },
         "model.ChartData": {
             "type": "object",
             "properties": {

+ 204 - 26
core/docs/swagger.yaml

@@ -35,7 +35,7 @@ definitions:
       status:
         type: integer
       type:
-        type: integer
+        $ref: '#/definitions/model.ChannelType'
     type: object
   controller.AddTokenRequest:
     properties:
@@ -107,6 +107,15 @@ definitions:
       tpm_ratio:
         type: number
     type: object
+  controller.EnabledModelChannel:
+    properties:
+      id:
+        type: integer
+      name:
+        type: string
+      type:
+        $ref: '#/definitions/model.ChannelType'
+    type: object
   controller.GetModelConfigsByModelsContainsRequest:
     properties:
       models:
@@ -470,7 +479,7 @@ definitions:
       status:
         type: integer
       type:
-        type: integer
+        $ref: '#/definitions/model.ChannelType'
       used_amount:
         type: number
     type: object
@@ -488,7 +497,7 @@ definitions:
       channel_name:
         type: string
       channel_type:
-        type: integer
+        $ref: '#/definitions/model.ChannelType'
       code:
         type: integer
       mode:
@@ -504,6 +513,78 @@ definitions:
       took:
         type: number
     type: object
+  model.ChannelType:
+    enum:
+    - 1
+    - 3
+    - 12
+    - 13
+    - 14
+    - 15
+    - 16
+    - 17
+    - 18
+    - 19
+    - 20
+    - 23
+    - 24
+    - 25
+    - 26
+    - 27
+    - 28
+    - 29
+    - 30
+    - 31
+    - 32
+    - 33
+    - 34
+    - 35
+    - 36
+    - 37
+    - 40
+    - 41
+    - 42
+    - 43
+    - 44
+    - 45
+    - 46
+    - 47
+    type: integer
+    x-enum-varnames:
+    - ChannelTypeOpenAI
+    - ChannelTypeAzure
+    - ChannelTypeGoogleGeminiOpenAI
+    - ChannelTypeBaiduV2
+    - ChannelTypeAnthropic
+    - ChannelTypeBaidu
+    - ChannelTypeZhipu
+    - ChannelTypeAli
+    - ChannelTypeXunfei
+    - ChannelTypeAI360
+    - ChannelTypeOpenRouter
+    - ChannelTypeTencent
+    - ChannelTypeGoogleGemini
+    - ChannelTypeMoonshot
+    - ChannelTypeBaichuan
+    - ChannelTypeMinimax
+    - ChannelTypeMistral
+    - ChannelTypeGroq
+    - ChannelTypeOllama
+    - ChannelTypeLingyiwanwu
+    - ChannelTypeStepfun
+    - ChannelTypeAWS
+    - ChannelTypeCoze
+    - ChannelTypeCohere
+    - ChannelTypeDeepseek
+    - ChannelTypeCloudflare
+    - ChannelTypeDoubao
+    - ChannelTypeNovita
+    - ChannelTypeVertexAI
+    - ChannelTypeSiliconflow
+    - ChannelTypeDoubaoAudio
+    - ChannelTypeXAI
+    - ChannelTypeDoc2x
+    - ChannelTypeJina
   model.ChartData:
     properties:
       cache_creation_tokens:
@@ -2046,28 +2127,6 @@ paths:
       summary: Get channel type metadata
       tags:
       - channels
-  /api/channels/type_names:
-    get:
-      description: Returns a list of all available channel type names
-      produces:
-      - application/json
-      responses:
-        "200":
-          description: OK
-          schema:
-            allOf:
-            - $ref: '#/definitions/middleware.APIResponse'
-            - properties:
-                data:
-                  additionalProperties:
-                    type: string
-                  type: object
-              type: object
-      security:
-      - ApiKeyAuth: []
-      summary: Get all channel type names
-      tags:
-      - channels
   /api/dashboard:
     get:
       description: Returns the general dashboard data including usage statistics and
@@ -4169,10 +4228,45 @@ paths:
       description: Returns a list of channel builtin models by type
       parameters:
       - description: Channel type
+        enum:
+        - 1
+        - 3
+        - 12
+        - 13
+        - 14
+        - 15
+        - 16
+        - 17
+        - 18
+        - 19
+        - 20
+        - 23
+        - 24
+        - 25
+        - 26
+        - 27
+        - 28
+        - 29
+        - 30
+        - 31
+        - 32
+        - 33
+        - 34
+        - 35
+        - 36
+        - 37
+        - 40
+        - 41
+        - 42
+        - 43
+        - 44
+        - 45
+        - 46
+        - 47
         in: path
         name: type
         required: true
-        type: string
+        type: integer
       produces:
       - application/json
       responses:
@@ -4192,6 +4286,62 @@ paths:
       summary: Get channel builtin models by type
       tags:
       - model
+  /api/models/channel:
+    get:
+      description: Returns a list of enabled models
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            allOf:
+            - $ref: '#/definitions/middleware.APIResponse'
+            - properties:
+                data:
+                  additionalProperties:
+                    additionalProperties:
+                      items:
+                        $ref: '#/definitions/controller.EnabledModelChannel'
+                      type: array
+                    type: object
+                  type: object
+              type: object
+      security:
+      - ApiKeyAuth: []
+      summary: Get enabled models and channels
+      tags:
+      - model
+  /api/models/channel/{set}:
+    get:
+      description: Returns a list of enabled models and channels by set
+      parameters:
+      - description: Models set
+        in: path
+        name: set
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            allOf:
+            - $ref: '#/definitions/middleware.APIResponse'
+            - properties:
+                data:
+                  additionalProperties:
+                    items:
+                      $ref: '#/definitions/controller.EnabledModelChannel'
+                    type: array
+                  type: object
+              type: object
+      security:
+      - ApiKeyAuth: []
+      summary: Get enabled models and channels by set
+      tags:
+      - model
   /api/models/default:
     get:
       description: Returns a list of channel default models and mapping
@@ -4288,6 +4438,34 @@ paths:
       summary: Get enabled models
       tags:
       - model
+  /api/models/enabled/{set}:
+    get:
+      description: Returns a list of enabled models by set
+      parameters:
+      - description: Models set
+        in: path
+        name: set
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            allOf:
+            - $ref: '#/definitions/middleware.APIResponse'
+            - properties:
+                data:
+                  items:
+                    $ref: '#/definitions/model.ModelConfig'
+                  type: array
+              type: object
+      security:
+      - ApiKeyAuth: []
+      summary: Get enabled models by set
+      tags:
+      - model
   /api/monitor:
     delete:
       description: Clears all model errors

+ 1 - 3
core/middleware/auth.go

@@ -187,9 +187,7 @@ func SetLogChannelFields(fields logrus.Fields, channel meta.ChannelMeta) {
 	}
 	if channel.Type > 0 {
 		fields["chtype"] = channel.Type
-	}
-	if channel.TypeName != "" {
-		fields["chtype_name"] = channel.TypeName
+		fields["chtype_name"] = channel.Type.String()
 	}
 }
 

+ 10 - 5
core/model/cache.go

@@ -453,11 +453,16 @@ type ModelConfigCache interface {
 type ModelCaches struct {
 	ModelConfig ModelConfigCache
 
-	EnabledModelsBySet       map[string][]string
+	// map[set][]model
+	EnabledModelsBySet map[string][]string
+	// map[set][]modelconfig
 	EnabledModelConfigsBySet map[string][]*ModelConfig
-	EnabledModelConfigsMap   map[string]*ModelConfig
+	// map[model]modelconfig
+	EnabledModelConfigsMap map[string]*ModelConfig
 
-	EnabledModel2ChannelsBySet  map[string]map[string][]*Channel
+	// map[set]map[model][]channel
+	EnabledModel2ChannelsBySet map[string]map[string][]*Channel
+	// map[set]map[model][]channel
 	DisabledModel2ChannelsBySet map[string]map[string][]*Channel
 }
 
@@ -618,7 +623,7 @@ func initializeModelConfigCache() (ModelConfigCache, error) {
 
 func initializeChannelModels(channel *Channel) {
 	if len(channel.Models) == 0 {
-		channel.Models = config.GetDefaultChannelModels()[channel.Type]
+		channel.Models = config.GetDefaultChannelModels()[int(channel.Type)]
 		return
 	}
 
@@ -637,7 +642,7 @@ func initializeChannelModels(channel *Channel) {
 
 func initializeChannelModelMapping(channel *Channel) {
 	if len(channel.ModelMapping) == 0 {
-		channel.ModelMapping = config.GetDefaultChannelModelMapping()[channel.Type]
+		channel.ModelMapping = config.GetDefaultChannelModelMapping()[int(channel.Type)]
 	}
 }
 

+ 1 - 1
core/model/channel.go

@@ -50,7 +50,7 @@ type Channel struct {
 	UsedAmount              float64           `gorm:"index"                              json:"used_amount"`
 	RequestCount            int               `gorm:"index"                              json:"request_count"`
 	Status                  int               `gorm:"default:1;index"                    json:"status"`
-	Type                    int               `gorm:"default:0;index"                    json:"type"`
+	Type                    ChannelType       `gorm:"default:0;index"                    json:"type"`
 	Priority                int32             `json:"priority"`
 	EnabledAutoBalanceCheck bool              `json:"enabled_auto_balance_check"`
 	BalanceThreshold        float64           `json:"balance_threshold"`

+ 11 - 11
core/model/channeltest.go

@@ -8,17 +8,17 @@ import (
 )
 
 type ChannelTest struct {
-	TestAt      time.Time `json:"test_at"`
-	Model       string    `gorm:"primaryKey"   json:"model"`
-	ActualModel string    `json:"actual_model"`
-	Response    string    `gorm:"type:text"    json:"response"`
-	ChannelName string    `json:"channel_name"`
-	ChannelType int       `json:"channel_type"`
-	ChannelID   int       `gorm:"primaryKey"   json:"channel_id"`
-	Took        float64   `json:"took"`
-	Success     bool      `json:"success"`
-	Mode        mode.Mode `json:"mode"`
-	Code        int       `json:"code"`
+	TestAt      time.Time   `json:"test_at"`
+	Model       string      `gorm:"primaryKey"   json:"model"`
+	ActualModel string      `json:"actual_model"`
+	Response    string      `gorm:"type:text"    json:"response"`
+	ChannelName string      `json:"channel_name"`
+	ChannelType ChannelType `json:"channel_type"`
+	ChannelID   int         `gorm:"primaryKey"   json:"channel_id"`
+	Took        float64     `json:"took"`
+	Success     bool        `json:"success"`
+	Mode        mode.Mode   `json:"mode"`
+	Code        int         `json:"code"`
 }
 
 func (ct *ChannelTest) MarshalJSON() ([]byte, error) {

+ 94 - 0
core/model/chtype.go

@@ -0,0 +1,94 @@
+package model
+
+import "fmt"
+
+type ChannelType int
+
+func (c ChannelType) String() string {
+	if name, ok := channelTypeNames[c]; ok {
+		return name
+	}
+	return fmt.Sprintf("unknow(%d)", c)
+}
+
+const (
+	ChannelTypeOpenAI             ChannelType = 1
+	ChannelTypeAzure              ChannelType = 3
+	ChannelTypeGoogleGeminiOpenAI ChannelType = 12
+	ChannelTypeBaiduV2            ChannelType = 13
+	ChannelTypeAnthropic          ChannelType = 14
+	ChannelTypeBaidu              ChannelType = 15
+	ChannelTypeZhipu              ChannelType = 16
+	ChannelTypeAli                ChannelType = 17
+	ChannelTypeXunfei             ChannelType = 18
+	ChannelTypeAI360              ChannelType = 19
+	ChannelTypeOpenRouter         ChannelType = 20
+	ChannelTypeTencent            ChannelType = 23
+	ChannelTypeGoogleGemini       ChannelType = 24
+	ChannelTypeMoonshot           ChannelType = 25
+	ChannelTypeBaichuan           ChannelType = 26
+	ChannelTypeMinimax            ChannelType = 27
+	ChannelTypeMistral            ChannelType = 28
+	ChannelTypeGroq               ChannelType = 29
+	ChannelTypeOllama             ChannelType = 30
+	ChannelTypeLingyiwanwu        ChannelType = 31
+	ChannelTypeStepfun            ChannelType = 32
+	ChannelTypeAWS                ChannelType = 33
+	ChannelTypeCoze               ChannelType = 34
+	ChannelTypeCohere             ChannelType = 35
+	ChannelTypeDeepseek           ChannelType = 36
+	ChannelTypeCloudflare         ChannelType = 37
+	ChannelTypeDoubao             ChannelType = 40
+	ChannelTypeNovita             ChannelType = 41
+	ChannelTypeVertexAI           ChannelType = 42
+	ChannelTypeSiliconflow        ChannelType = 43
+	ChannelTypeDoubaoAudio        ChannelType = 44
+	ChannelTypeXAI                ChannelType = 45
+	ChannelTypeDoc2x              ChannelType = 46
+	ChannelTypeJina               ChannelType = 47
+)
+
+var channelTypeNames = map[ChannelType]string{
+	ChannelTypeOpenAI:             "openai",
+	ChannelTypeAzure:              "azure",
+	ChannelTypeGoogleGeminiOpenAI: "google gemini (openai)",
+	ChannelTypeBaiduV2:            "baidu v2",
+	ChannelTypeAnthropic:          "anthropic",
+	ChannelTypeBaidu:              "baidu",
+	ChannelTypeZhipu:              "zhipu",
+	ChannelTypeAli:                "ali",
+	ChannelTypeXunfei:             "xunfei",
+	ChannelTypeAI360:              "ai360",
+	ChannelTypeOpenRouter:         "openrouter",
+	ChannelTypeTencent:            "tencent",
+	ChannelTypeGoogleGemini:       "google gemini",
+	ChannelTypeMoonshot:           "moonshot",
+	ChannelTypeBaichuan:           "baichuan",
+	ChannelTypeMinimax:            "minimax",
+	ChannelTypeMistral:            "mistral",
+	ChannelTypeGroq:               "groq",
+	ChannelTypeOllama:             "ollama",
+	ChannelTypeLingyiwanwu:        "lingyiwanwu",
+	ChannelTypeStepfun:            "stepfun",
+	ChannelTypeAWS:                "aws",
+	ChannelTypeCoze:               "coze",
+	ChannelTypeCohere:             "Cohere",
+	ChannelTypeDeepseek:           "deepseek",
+	ChannelTypeCloudflare:         "cloudflare",
+	ChannelTypeDoubao:             "doubao",
+	ChannelTypeNovita:             "novita",
+	ChannelTypeVertexAI:           "vertexai",
+	ChannelTypeSiliconflow:        "siliconflow",
+	ChannelTypeDoubaoAudio:        "doubao audio",
+	ChannelTypeXAI:                "xai",
+	ChannelTypeDoc2x:              "doc2x",
+	ChannelTypeJina:               "jina",
+}
+
+func AllChannelTypes() []ChannelType {
+	types := make([]ChannelType, 0, len(channelTypeNames))
+	for t := range channelTypeNames {
+		types = append(types, t)
+	}
+	return types
+}

+ 0 - 4
core/relay/adaptor/ai360/adaptor.go

@@ -18,7 +18,3 @@ func (a *Adaptor) GetBaseURL() string {
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "ai360"
-}

+ 0 - 4
core/relay/adaptor/ali/adaptor.go

@@ -143,7 +143,3 @@ func getEnableSearch(reqBody []byte) (bool, error) {
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "ali"
-}

+ 0 - 4
core/relay/adaptor/anthropic/adaptor.go

@@ -100,7 +100,3 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "anthropic"
-}

+ 0 - 4
core/relay/adaptor/aws/adaptor.go

@@ -49,10 +49,6 @@ func (a *Adaptor) GetModelList() (models []*model.ModelConfig) {
 	return
 }
 
-func (a *Adaptor) GetChannelName() string {
-	return "aws"
-}
-
 func (a *Adaptor) GetRequestURL(_ *meta.Meta) (string, error) {
 	return "", nil
 }

+ 0 - 4
core/relay/adaptor/azure/main.go

@@ -56,7 +56,3 @@ func (a *Adaptor) SetupRequestHeader(meta *meta.Meta, _ *gin.Context, req *http.
 	req.Header.Set("Api-Key", token)
 	return nil
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "azure"
-}

+ 0 - 4
core/relay/adaptor/baichuan/adaptor.go

@@ -18,7 +18,3 @@ func (a *Adaptor) GetBaseURL() string {
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "baichuan"
-}

+ 0 - 4
core/relay/adaptor/baidu/adaptor.go

@@ -131,7 +131,3 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "baidu"
-}

+ 0 - 4
core/relay/adaptor/baiduv2/adaptor.go

@@ -94,7 +94,3 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "baidu v2"
-}

+ 0 - 4
core/relay/adaptor/cloudflare/adaptor.go

@@ -53,7 +53,3 @@ func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "cloudflare"
-}

+ 0 - 4
core/relay/adaptor/cohere/adaptor.go

@@ -71,7 +71,3 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "Cohere"
-}

+ 0 - 4
core/relay/adaptor/coze/adaptor.go

@@ -90,7 +90,3 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "coze"
-}

+ 0 - 4
core/relay/adaptor/deepseek/adaptor.go

@@ -21,7 +21,3 @@ func (a *Adaptor) GetBaseURL() string {
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "deepseek"
-}

+ 0 - 4
core/relay/adaptor/doc2x/adaptor.go

@@ -64,7 +64,3 @@ func (a *Adaptor) SetupRequestHeader(meta *meta.Meta, _ *gin.Context, req *http.
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "doc2x"
-}

+ 0 - 4
core/relay/adaptor/doubao/main.go

@@ -148,10 +148,6 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 	return usage, err
 }
 
-func (a *Adaptor) GetChannelName() string {
-	return "doubao"
-}
-
 func (a *Adaptor) GetBalance(_ *model.Channel) (float64, error) {
 	return 0, adaptor.ErrGetBalanceNotImplemented
 }

+ 0 - 4
core/relay/adaptor/doubaoaudio/main.go

@@ -83,7 +83,3 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 		)
 	}
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "doubao audio"
-}

+ 0 - 4
core/relay/adaptor/gemini/adaptor.go

@@ -90,7 +90,3 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "google gemini"
-}

+ 0 - 4
core/relay/adaptor/geminiopenai/adaptor.go

@@ -19,7 +19,3 @@ func (a *Adaptor) GetBaseURL() string {
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return gemini.ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "google gemini (openai)"
-}

+ 0 - 4
core/relay/adaptor/groq/adaptor.go

@@ -18,7 +18,3 @@ func (a *Adaptor) GetBaseURL() string {
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "groq"
-}

+ 0 - 1
core/relay/adaptor/interface.go

@@ -12,7 +12,6 @@ import (
 )
 
 type Adaptor interface {
-	GetChannelName() string
 	GetBaseURL() string
 	GetRequestURL(meta *meta.Meta) (string, error)
 	SetupRequestHeader(meta *meta.Meta, c *gin.Context, req *http.Request) error

+ 0 - 4
core/relay/adaptor/jina/adaptor.go

@@ -43,7 +43,3 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "jina"
-}

+ 0 - 4
core/relay/adaptor/lingyiwanwu/adaptor.go

@@ -20,10 +20,6 @@ func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
 
-func (a *Adaptor) GetChannelName() string {
-	return "lingyiwanwu"
-}
-
 func (a *Adaptor) GetBalance(_ *model.Channel) (float64, error) {
 	return 0, adaptor.ErrGetBalanceNotImplemented
 }

+ 0 - 4
core/relay/adaptor/minimax/adaptor.go

@@ -74,10 +74,6 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 	}
 }
 
-func (a *Adaptor) GetChannelName() string {
-	return "minimax"
-}
-
 func (a *Adaptor) GetBalance(_ *model.Channel) (float64, error) {
 	return 0, adaptor.ErrGetBalanceNotImplemented
 }

+ 0 - 4
core/relay/adaptor/mistral/adaptor.go

@@ -18,7 +18,3 @@ func (a *Adaptor) GetBaseURL() string {
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "mistral"
-}

+ 0 - 4
core/relay/adaptor/moonshot/adaptor.go

@@ -18,7 +18,3 @@ func (a *Adaptor) GetBaseURL() string {
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "moonshot"
-}

+ 0 - 4
core/relay/adaptor/novita/adaptor.go

@@ -18,7 +18,3 @@ func (a *Adaptor) GetBaseURL() string {
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "novita"
-}

+ 0 - 4
core/relay/adaptor/ollama/adaptor.go

@@ -80,7 +80,3 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "ollama"
-}

+ 0 - 4
core/relay/adaptor/openai/adaptor.go

@@ -183,7 +183,3 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "openai"
-}

+ 0 - 4
core/relay/adaptor/openrouter/adaptor.go

@@ -103,7 +103,3 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return openai.ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "openrouter"
-}

+ 0 - 4
core/relay/adaptor/siliconflow/adaptor.go

@@ -28,10 +28,6 @@ func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
 
-func (a *Adaptor) GetChannelName() string {
-	return "siliconflow"
-}
-
 //nolint:gocritic
 func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Response) (usage *model.Usage, err *relaymodel.ErrorWithStatusCode) {
 	usage, err = a.Adaptor.DoResponse(meta, c, resp)

+ 0 - 4
core/relay/adaptor/stepfun/adaptor.go

@@ -34,10 +34,6 @@ func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
 
-func (a *Adaptor) GetChannelName() string {
-	return "stepfun"
-}
-
 func (a *Adaptor) GetBalance(_ *model.Channel) (float64, error) {
 	return 0, adaptor.ErrGetBalanceNotImplemented
 }

+ 0 - 4
core/relay/adaptor/tencent/adaptor.go

@@ -22,10 +22,6 @@ func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
 
-func (a *Adaptor) GetChannelName() string {
-	return "tencent"
-}
-
 func (a *Adaptor) GetBalance(_ *model.Channel) (float64, error) {
 	return 0, adaptor.ErrGetBalanceNotImplemented
 }

+ 0 - 6
core/relay/adaptor/vertexai/adaptor.go

@@ -19,8 +19,6 @@ import (
 
 var _ channelhelper.Adaptor = new(Adaptor)
 
-const channelName = "vertexai"
-
 type Adaptor struct{}
 
 func (a *Adaptor) GetBaseURL() string {
@@ -54,10 +52,6 @@ func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return modelList
 }
 
-func (a *Adaptor) GetChannelName() string {
-	return channelName
-}
-
 func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
 	var suffix string
 	if strings.HasPrefix(meta.ActualModel, "gemini") {

+ 0 - 4
core/relay/adaptor/xai/adaptor.go

@@ -31,7 +31,3 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
 func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
-
-func (a *Adaptor) GetChannelName() string {
-	return "xai"
-}

+ 0 - 4
core/relay/adaptor/xunfei/adaptor.go

@@ -38,10 +38,6 @@ func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
 
-func (a *Adaptor) GetChannelName() string {
-	return "xunfei"
-}
-
 func (a *Adaptor) GetBalance(_ *model.Channel) (float64, error) {
 	return 0, adaptor.ErrGetBalanceNotImplemented
 }

+ 0 - 4
core/relay/adaptor/zhipu/adaptor.go

@@ -36,10 +36,6 @@ func (a *Adaptor) GetModelList() []*model.ModelConfig {
 	return ModelList
 }
 
-func (a *Adaptor) GetChannelName() string {
-	return "zhipu"
-}
-
 func (a *Adaptor) GetBalance(_ *model.Channel) (float64, error) {
 	return 0, adaptor.ErrGetBalanceNotImplemented
 }

+ 40 - 53
core/relay/channeltype/define.go

@@ -1,6 +1,7 @@
 package channeltype
 
 import (
+	"github.com/labring/aiproxy/core/model"
 	"github.com/labring/aiproxy/core/relay/adaptor"
 	"github.com/labring/aiproxy/core/relay/adaptor/ai360"
 	"github.com/labring/aiproxy/core/relay/adaptor/ali"
@@ -38,45 +39,45 @@ import (
 	"github.com/labring/aiproxy/core/relay/adaptor/zhipu"
 )
 
-var ChannelAdaptor = map[int]adaptor.Adaptor{
-	1:  &openai.Adaptor{},
-	3:  &azure.Adaptor{},
-	12: &geminiopenai.Adaptor{},
-	13: &baiduv2.Adaptor{},
-	14: &anthropic.Adaptor{},
-	15: &baidu.Adaptor{},
-	16: &zhipu.Adaptor{},
-	17: &ali.Adaptor{},
-	18: &xunfei.Adaptor{},
-	19: &ai360.Adaptor{},
-	20: &openrouter.Adaptor{},
-	23: &tencent.Adaptor{},
-	24: &gemini.Adaptor{},
-	25: &moonshot.Adaptor{},
-	26: &baichuan.Adaptor{},
-	27: &minimax.Adaptor{},
-	28: &mistral.Adaptor{},
-	29: &groq.Adaptor{},
-	30: &ollama.Adaptor{},
-	31: &lingyiwanwu.Adaptor{},
-	32: &stepfun.Adaptor{},
-	33: &aws.Adaptor{},
-	34: &coze.Adaptor{},
-	35: &cohere.Adaptor{},
-	36: &deepseek.Adaptor{},
-	37: &cloudflare.Adaptor{},
-	40: &doubao.Adaptor{},
-	41: &novita.Adaptor{},
-	42: &vertexai.Adaptor{},
-	43: &siliconflow.Adaptor{},
-	44: &doubaoaudio.Adaptor{},
-	45: &xai.Adaptor{},
-	46: &doc2x.Adaptor{},
-	47: &jina.Adaptor{},
+var ChannelAdaptor = map[model.ChannelType]adaptor.Adaptor{
+	model.ChannelTypeOpenAI:             &openai.Adaptor{},
+	model.ChannelTypeAzure:              &azure.Adaptor{},
+	model.ChannelTypeGoogleGeminiOpenAI: &geminiopenai.Adaptor{},
+	model.ChannelTypeBaiduV2:            &baiduv2.Adaptor{},
+	model.ChannelTypeAnthropic:          &anthropic.Adaptor{},
+	model.ChannelTypeBaidu:              &baidu.Adaptor{},
+	model.ChannelTypeZhipu:              &zhipu.Adaptor{},
+	model.ChannelTypeAli:                &ali.Adaptor{},
+	model.ChannelTypeXunfei:             &xunfei.Adaptor{},
+	model.ChannelTypeAI360:              &ai360.Adaptor{},
+	model.ChannelTypeOpenRouter:         &openrouter.Adaptor{},
+	model.ChannelTypeTencent:            &tencent.Adaptor{},
+	model.ChannelTypeGoogleGemini:       &gemini.Adaptor{},
+	model.ChannelTypeMoonshot:           &moonshot.Adaptor{},
+	model.ChannelTypeBaichuan:           &baichuan.Adaptor{},
+	model.ChannelTypeMinimax:            &minimax.Adaptor{},
+	model.ChannelTypeMistral:            &mistral.Adaptor{},
+	model.ChannelTypeGroq:               &groq.Adaptor{},
+	model.ChannelTypeOllama:             &ollama.Adaptor{},
+	model.ChannelTypeLingyiwanwu:        &lingyiwanwu.Adaptor{},
+	model.ChannelTypeStepfun:            &stepfun.Adaptor{},
+	model.ChannelTypeAWS:                &aws.Adaptor{},
+	model.ChannelTypeCoze:               &coze.Adaptor{},
+	model.ChannelTypeCohere:             &cohere.Adaptor{},
+	model.ChannelTypeDeepseek:           &deepseek.Adaptor{},
+	model.ChannelTypeCloudflare:         &cloudflare.Adaptor{},
+	model.ChannelTypeDoubao:             &doubao.Adaptor{},
+	model.ChannelTypeNovita:             &novita.Adaptor{},
+	model.ChannelTypeVertexAI:           &vertexai.Adaptor{},
+	model.ChannelTypeSiliconflow:        &siliconflow.Adaptor{},
+	model.ChannelTypeDoubaoAudio:        &doubaoaudio.Adaptor{},
+	model.ChannelTypeXAI:                &xai.Adaptor{},
+	model.ChannelTypeDoc2x:              &doc2x.Adaptor{},
+	model.ChannelTypeJina:               &jina.Adaptor{},
 }
 
-func GetAdaptor(channel int) (adaptor.Adaptor, bool) {
-	a, ok := ChannelAdaptor[channel]
+func GetAdaptor(channelType model.ChannelType) (adaptor.Adaptor, bool) {
+	a, ok := ChannelAdaptor[channelType]
 	return a, ok
 }
 
@@ -86,25 +87,15 @@ type AdaptorMeta struct {
 	DefaultBaseURL string `json:"defaultBaseUrl"`
 }
 
-var (
-	ChannelNames = map[int]string{}
-	ChannelMetas = map[int]AdaptorMeta{}
-)
+var ChannelMetas = map[model.ChannelType]AdaptorMeta{}
 
 func init() {
-	names := make(map[string]struct{})
 	for i, adaptor := range ChannelAdaptor {
-		name := adaptor.GetChannelName()
-		if _, ok := names[name]; ok {
-			panic("duplicate channel name: " + name)
-		}
-		names[name] = struct{}{}
 		ChannelMetas[i] = AdaptorMeta{
-			Name:           name,
+			Name:           i.String(),
 			KeyHelp:        getAdaptorKeyHelp(adaptor),
 			DefaultBaseURL: adaptor.GetBaseURL(),
 		}
-		ChannelNames[i] = name
 	}
 }
 
@@ -114,7 +105,3 @@ func getAdaptorKeyHelp(a adaptor.Adaptor) string {
 	}
 	return ""
 }
-
-func GetChannelName(channel int) string {
-	return ChannelNames[channel]
-}

+ 5 - 12
core/relay/meta/meta.go

@@ -9,12 +9,11 @@ import (
 )
 
 type ChannelMeta struct {
-	Name     string
-	BaseURL  string
-	Key      string
-	ID       int
-	Type     int
-	TypeName string
+	Name    string
+	BaseURL string
+	Key     string
+	ID      int
+	Type    model.ChannelType
 }
 
 type Meta struct {
@@ -80,12 +79,6 @@ func WithRequestUsage(requestUsage model.Usage) Option {
 	}
 }
 
-func WithChannelTypeName(typeName string) Option {
-	return func(meta *Meta) {
-		meta.Channel.TypeName = typeName
-	}
-}
-
 func NewMeta(
 	channel *model.Channel,
 	mode mode.Mode,

+ 3 - 1
core/router/api.go

@@ -26,6 +26,9 @@ func SetAPIRouter(router *gin.Engine) {
 			modelsRoute.GET("/builtin/channel", controller.ChannelBuiltinModels)
 			modelsRoute.GET("/builtin/channel/:type", controller.ChannelBuiltinModelsByType)
 			modelsRoute.GET("/enabled", controller.EnabledModels)
+			modelsRoute.GET("/enabled/:set", controller.EnabledModelsSet)
+			modelsRoute.GET("/channel", controller.EnabledModelChannels)
+			modelsRoute.GET("/channel/:set", controller.EnabledModelChannelsSet)
 			modelsRoute.GET("/default", controller.ChannelDefaultModelsAndMapping)
 			modelsRoute.GET("/default/:type", controller.ChannelDefaultModelsAndMappingByType)
 		}
@@ -88,7 +91,6 @@ func SetAPIRouter(router *gin.Engine) {
 		{
 			channelsRoute.GET("/", controller.GetChannels)
 			channelsRoute.GET("/all", controller.GetAllChannels)
-			channelsRoute.GET("/type_names", controller.ChannelTypeNames)
 			channelsRoute.GET("/type_metas", controller.ChannelTypeMetas)
 			channelsRoute.POST("/", controller.AddChannels)
 			channelsRoute.GET("/search", controller.SearchChannels)