api_type.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package constant
  2. import (
  3. "one-api/common"
  4. )
  5. const (
  6. APITypeOpenAI = iota
  7. APITypeAnthropic
  8. APITypePaLM
  9. APITypeBaidu
  10. APITypeZhipu
  11. APITypeAli
  12. APITypeXunfei
  13. APITypeAIProxyLibrary
  14. APITypeTencent
  15. APITypeGemini
  16. APITypeZhipuV4
  17. APITypeOllama
  18. APITypePerplexity
  19. APITypeAws
  20. APITypeCohere
  21. APITypeDify
  22. APITypeJina
  23. APITypeCloudflare
  24. APITypeSiliconFlow
  25. APITypeVertexAi
  26. APITypeMistral
  27. APITypeDeepSeek
  28. APITypeMokaAI
  29. APITypeVolcEngine
  30. APITypeBaiduV2
  31. APITypeOpenRouter
  32. APITypeXinference
  33. APITypeXai
  34. APITypeDummy // this one is only for count, do not add any channel after this
  35. )
  36. func ChannelType2APIType(channelType int) (int, bool) {
  37. apiType := -1
  38. switch channelType {
  39. case common.ChannelTypeOpenAI:
  40. apiType = APITypeOpenAI
  41. case common.ChannelTypeAnthropic:
  42. apiType = APITypeAnthropic
  43. case common.ChannelTypeBaidu:
  44. apiType = APITypeBaidu
  45. case common.ChannelTypePaLM:
  46. apiType = APITypePaLM
  47. case common.ChannelTypeZhipu:
  48. apiType = APITypeZhipu
  49. case common.ChannelTypeAli:
  50. apiType = APITypeAli
  51. case common.ChannelTypeXunfei:
  52. apiType = APITypeXunfei
  53. case common.ChannelTypeAIProxyLibrary:
  54. apiType = APITypeAIProxyLibrary
  55. case common.ChannelTypeTencent:
  56. apiType = APITypeTencent
  57. case common.ChannelTypeGemini:
  58. apiType = APITypeGemini
  59. case common.ChannelTypeZhipu_v4:
  60. apiType = APITypeZhipuV4
  61. case common.ChannelTypeOllama:
  62. apiType = APITypeOllama
  63. case common.ChannelTypePerplexity:
  64. apiType = APITypePerplexity
  65. case common.ChannelTypeAws:
  66. apiType = APITypeAws
  67. case common.ChannelTypeCohere:
  68. apiType = APITypeCohere
  69. case common.ChannelTypeDify:
  70. apiType = APITypeDify
  71. case common.ChannelTypeJina:
  72. apiType = APITypeJina
  73. case common.ChannelCloudflare:
  74. apiType = APITypeCloudflare
  75. case common.ChannelTypeSiliconFlow:
  76. apiType = APITypeSiliconFlow
  77. case common.ChannelTypeVertexAi:
  78. apiType = APITypeVertexAi
  79. case common.ChannelTypeMistral:
  80. apiType = APITypeMistral
  81. case common.ChannelTypeDeepSeek:
  82. apiType = APITypeDeepSeek
  83. case common.ChannelTypeMokaAI:
  84. apiType = APITypeMokaAI
  85. case common.ChannelTypeVolcEngine:
  86. apiType = APITypeVolcEngine
  87. case common.ChannelTypeBaiduV2:
  88. apiType = APITypeBaiduV2
  89. case common.ChannelTypeOpenRouter:
  90. apiType = APITypeOpenRouter
  91. case common.ChannelTypeXinference:
  92. apiType = APITypeXinference
  93. case common.ChannelTypeXai:
  94. apiType = APITypeXai
  95. }
  96. if apiType == -1 {
  97. return APITypeOpenAI, false
  98. }
  99. return apiType, true
  100. }