api_type.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package common
  2. import "one-api/constant"
  3. func ChannelType2APIType(channelType int) (int, bool) {
  4. apiType := -1
  5. switch channelType {
  6. case constant.ChannelTypeOpenAI:
  7. apiType = constant.APITypeOpenAI
  8. case constant.ChannelTypeAnthropic:
  9. apiType = constant.APITypeAnthropic
  10. case constant.ChannelTypeBaidu:
  11. apiType = constant.APITypeBaidu
  12. case constant.ChannelTypePaLM:
  13. apiType = constant.APITypePaLM
  14. case constant.ChannelTypeZhipu:
  15. apiType = constant.APITypeZhipu
  16. case constant.ChannelTypeAli:
  17. apiType = constant.APITypeAli
  18. case constant.ChannelTypeXunfei:
  19. apiType = constant.APITypeXunfei
  20. case constant.ChannelTypeAIProxyLibrary:
  21. apiType = constant.APITypeAIProxyLibrary
  22. case constant.ChannelTypeTencent:
  23. apiType = constant.APITypeTencent
  24. case constant.ChannelTypeGemini:
  25. apiType = constant.APITypeGemini
  26. case constant.ChannelTypeZhipu_v4:
  27. apiType = constant.APITypeZhipuV4
  28. case constant.ChannelTypeOllama:
  29. apiType = constant.APITypeOllama
  30. case constant.ChannelTypePerplexity:
  31. apiType = constant.APITypePerplexity
  32. case constant.ChannelTypeAws:
  33. apiType = constant.APITypeAws
  34. case constant.ChannelTypeCohere:
  35. apiType = constant.APITypeCohere
  36. case constant.ChannelTypeDify:
  37. apiType = constant.APITypeDify
  38. case constant.ChannelTypeJina:
  39. apiType = constant.APITypeJina
  40. case constant.ChannelCloudflare:
  41. apiType = constant.APITypeCloudflare
  42. case constant.ChannelTypeSiliconFlow:
  43. apiType = constant.APITypeSiliconFlow
  44. case constant.ChannelTypeVertexAi:
  45. apiType = constant.APITypeVertexAi
  46. case constant.ChannelTypeMistral:
  47. apiType = constant.APITypeMistral
  48. case constant.ChannelTypeDeepSeek:
  49. apiType = constant.APITypeDeepSeek
  50. case constant.ChannelTypeMokaAI:
  51. apiType = constant.APITypeMokaAI
  52. case constant.ChannelTypeVolcEngine:
  53. apiType = constant.APITypeVolcEngine
  54. case constant.ChannelTypeBaiduV2:
  55. apiType = constant.APITypeBaiduV2
  56. case constant.ChannelTypeOpenRouter:
  57. apiType = constant.APITypeOpenRouter
  58. case constant.ChannelTypeXinference:
  59. apiType = constant.APITypeXinference
  60. case constant.ChannelTypeXai:
  61. apiType = constant.APITypeXai
  62. case constant.ChannelTypeCoze:
  63. apiType = constant.APITypeCoze
  64. case constant.ChannelTypeJimeng:
  65. apiType = constant.APITypeJimeng
  66. }
  67. if apiType == -1 {
  68. return constant.APITypeOpenAI, false
  69. }
  70. return apiType, true
  71. }