api_type.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. APITypeCoze
  35. APITypeDummy // this one is only for count, do not add any channel after this
  36. )
  37. func ChannelType2APIType(channelType int) (int, bool) {
  38. apiType := -1
  39. switch channelType {
  40. case common.ChannelTypeOpenAI:
  41. apiType = APITypeOpenAI
  42. case common.ChannelTypeAnthropic:
  43. apiType = APITypeAnthropic
  44. case common.ChannelTypeBaidu:
  45. apiType = APITypeBaidu
  46. case common.ChannelTypePaLM:
  47. apiType = APITypePaLM
  48. case common.ChannelTypeZhipu:
  49. apiType = APITypeZhipu
  50. case common.ChannelTypeAli:
  51. apiType = APITypeAli
  52. case common.ChannelTypeXunfei:
  53. apiType = APITypeXunfei
  54. case common.ChannelTypeAIProxyLibrary:
  55. apiType = APITypeAIProxyLibrary
  56. case common.ChannelTypeTencent:
  57. apiType = APITypeTencent
  58. case common.ChannelTypeGemini:
  59. apiType = APITypeGemini
  60. case common.ChannelTypeZhipu_v4:
  61. apiType = APITypeZhipuV4
  62. case common.ChannelTypeOllama:
  63. apiType = APITypeOllama
  64. case common.ChannelTypePerplexity:
  65. apiType = APITypePerplexity
  66. case common.ChannelTypeAws:
  67. apiType = APITypeAws
  68. case common.ChannelTypeCohere:
  69. apiType = APITypeCohere
  70. case common.ChannelTypeDify:
  71. apiType = APITypeDify
  72. case common.ChannelTypeJina:
  73. apiType = APITypeJina
  74. case common.ChannelCloudflare:
  75. apiType = APITypeCloudflare
  76. case common.ChannelTypeSiliconFlow:
  77. apiType = APITypeSiliconFlow
  78. case common.ChannelTypeVertexAi:
  79. apiType = APITypeVertexAi
  80. case common.ChannelTypeMistral:
  81. apiType = APITypeMistral
  82. case common.ChannelTypeDeepSeek:
  83. apiType = APITypeDeepSeek
  84. case common.ChannelTypeMokaAI:
  85. apiType = APITypeMokaAI
  86. case common.ChannelTypeVolcEngine:
  87. apiType = APITypeVolcEngine
  88. case common.ChannelTypeBaiduV2:
  89. apiType = APITypeBaiduV2
  90. case common.ChannelTypeOpenRouter:
  91. apiType = APITypeOpenRouter
  92. case common.ChannelTypeXinference:
  93. apiType = APITypeXinference
  94. case common.ChannelTypeXai:
  95. apiType = APITypeXai
  96. case common.ChannelTypeCoze:
  97. apiType = APITypeCoze
  98. }
  99. if apiType == -1 {
  100. return APITypeOpenAI, false
  101. }
  102. return apiType, true
  103. }