config.example.yaml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. # AIProxy Configuration File
  2. # Priority: Environment Variables > Config File > Database
  3. # This file allows you to configure channels, model configs, and options without using the database
  4. # Channels Configuration
  5. # Note: Channels from YAML are assigned negative IDs automatically and are not persisted to database
  6. # They are merged with database channels in memory
  7. channels:
  8. - name: "openai-channel-1"
  9. type_name: "openai" # Can use type_name instead of numeric type
  10. key: "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  11. base_url: "https://api.openai.com"
  12. models:
  13. - "gpt-4"
  14. - "gpt-3.5-turbo"
  15. model_mapping:
  16. "gpt-4": "gpt-4-0613"
  17. status: 1 # 1=Enabled, 2=Disabled
  18. priority: 0
  19. balance: 100.0
  20. balance_threshold: 10.0
  21. enabled_auto_balance_check: true
  22. sets:
  23. - "default"
  24. config:
  25. spec:
  26. organization: "org-xxxxx"
  27. - name: "azure-channel-1"
  28. type_name: "azure" # Type name is case-insensitive
  29. key: "your-azure-api-key"
  30. base_url: "https://your-resource.openai.azure.com"
  31. models:
  32. - "gpt-4"
  33. status: 1
  34. priority: 1
  35. sets:
  36. - "default"
  37. - name: "claude-channel-1"
  38. type_name: "claude" # "claude" is an alias for "anthropic"
  39. key: "sk-ant-xxxxx"
  40. base_url: "https://api.anthropic.com"
  41. models:
  42. - "claude-3-opus-20240229"
  43. - "claude-3-sonnet-20240229"
  44. status: 1
  45. priority: 0
  46. sets:
  47. - "default"
  48. - "premium"
  49. # You can also use numeric type if preferred
  50. - name: "gemini-channel-1"
  51. type: 24 # Google Gemini
  52. key: "your-gemini-api-key"
  53. models:
  54. - "gemini-pro"
  55. status: 1
  56. # Model Configurations
  57. modelconfigs:
  58. - model: "gpt-4"
  59. owner: "openai"
  60. type_name: "chat" # Can use type_name instead of numeric type
  61. # OR use numeric type:
  62. # type: 1 # ChatCompletions
  63. rpm: 3500
  64. tpm: 80000
  65. retry_times: 3
  66. timeout_config:
  67. request_timeout: 300
  68. stream_request_timeout: 600
  69. warn_error_rate: 0.5
  70. max_error_rate: 0.8
  71. price:
  72. input: 0.03
  73. output: 0.06
  74. config:
  75. max_context_tokens: 8192
  76. max_output_tokens: 4096
  77. vision: false
  78. tool_choice: true
  79. - model: "gpt-3.5-turbo"
  80. owner: "openai"
  81. type_name: "chat"
  82. rpm: 3500
  83. tpm: 90000
  84. price:
  85. input: 0.0005
  86. output: 0.0015
  87. config:
  88. max_context_tokens: 16384
  89. max_output_tokens: 4096
  90. - model: "claude-3-opus-20240229"
  91. owner: "anthropic"
  92. type_name: "chat"
  93. rpm: 4000
  94. tpm: 400000
  95. price:
  96. input: 0.015
  97. output: 0.075
  98. config:
  99. max_context_tokens: 200000
  100. max_output_tokens: 4096
  101. vision: true
  102. - model: "claude-3-sonnet-20240229"
  103. owner: "anthropic"
  104. type_name: "chat"
  105. rpm: 4000
  106. tpm: 400000
  107. price:
  108. input: 0.003
  109. output: 0.015
  110. config:
  111. max_context_tokens: 200000
  112. max_output_tokens: 4096
  113. vision: true
  114. - model: "text-embedding-3-small"
  115. owner: "openai"
  116. type_name: "embedding" # Embedding model
  117. rpm: 3000
  118. tpm: 1000000
  119. price:
  120. input: 0.00002
  121. output: 0
  122. config:
  123. max_context_tokens: 8191
  124. - model: "dall-e-3"
  125. owner: "openai"
  126. type_name: "image" # Image generation
  127. rpm: 50
  128. image_quality_prices:
  129. "1024x1024":
  130. "standard": 0.040
  131. "hd": 0.080
  132. "1024x1792":
  133. "standard": 0.080
  134. "hd": 0.120
  135. "1792x1024":
  136. "standard": 0.080
  137. "hd": 0.120
  138. # System Options Configuration
  139. options:
  140. # Log retention settings (in hours)
  141. LogStorageHours: "168" # 7 days
  142. RetryLogStorageHours: "72" # 3 days
  143. LogDetailStorageHours: "24" # 1 day
  144. # Clean log batch size
  145. CleanLogBatchSize: "1000"
  146. # IP rate limiting
  147. IPGroupsThreshold: "100" # Requests per minute
  148. IPGroupsBanThreshold: "200" # Ban threshold
  149. # Log detail settings
  150. SaveAllLogDetail: "false"
  151. LogDetailRequestBodyMaxSize: "10000"
  152. LogDetailResponseBodyMaxSize: "10000"
  153. # Retry settings
  154. RetryTimes: "3"
  155. # Group settings
  156. GroupMaxTokenNum: "0" # 0 means unlimited
  157. GroupConsumeLevelRatio: '{"1":1,"2":0.9,"3":0.8}'
  158. # Error rate alerts
  159. DefaultWarnNotifyErrorRate: "0.5"
  160. # Usage alerts
  161. UsageAlertThreshold: "100"
  162. UsageAlertMinAvgThreshold: "10"
  163. # Fuzzy token threshold
  164. FuzzyTokenThreshold: "240000"
  165. # Disable serve (for maintenance)
  166. DisableServe: "false"