api_type.go 2.2 KB

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