-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.example.yaml
More file actions
272 lines (249 loc) · 8.96 KB
/
Copy pathconfig.example.yaml
File metadata and controls
272 lines (249 loc) · 8.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# AI Proxy Configuration Example
# Server bind address (default: 127.0.0.1, use 0.0.0.0 to listen on all interfaces)
bind: "127.0.0.1"
# Server listen port
listen: ":8642"
# Default max_tokens value for requests that don't specify one (default: 4096)
# This is used when converting requests to APIs that require max_tokens (e.g., Anthropic)
default_max_tokens: 4096
# Timeout in seconds for upstream requests (default: 60)
# This prevents requests from hanging indefinitely when upstream services are slow or unresponsive
upstream_request_timeout: 60
api-key:
- "your-api-key-1"
- "your-api-key-2"
# Rotating file log configuration (optional)
# If not specified or file is empty, logs go to stdout
log:
file: "" # Log file path, empty = stdout (e.g., "/var/log/aiproxy/aiproxy.log")
max_size: 100 # Max size in MB before rotation (default: 100)
max_backups: 3 # Max number of old files to keep (default: 3)
max_age: 28 # Max days to retain old files (default: 28)
compress: false # Compress rotated files with gzip (default: false)
model_fallback:
"claude-opus-4-6": "claude-opus-4-5"
"claude-opus-4-5": "claude-sonnet-4-6"
"claude-sonnet-4-6": "claude-sonnet-4-5"
"claude-sonnet-4-5": "claude-haiku-4-5"
"gpt-5.3-codex": "gpt-5.2-codex"
"gpt-5.2-codex": "gpt-5.2"
"gpt-5.2": "gpt-5.1-codex"
"gpt-5.1-codex": "gpt-5.1"
# Upstream services configuration
# Requests are load-balanced using weighted round-robin
# On 4xx/5xx errors, the next upstream is automatically tried
upstreams:
- name: "runanytime"
base_url: "https://runanytime.hxi.me"
# token accepts a single string or a list for round-robin with failover
token: "sk-"
weight: 10
api_type: "anthropic"
request_compression: "zstd"
enabled: false
http_headers:
"X-Custom-Header": "custom-value"
"X-Another-Header": "another-value"
# Model name mappings for this upstream
# Key: client model name, Value: upstream model name
model_mappings:
"claude-haiku-4-5": "claude-haiku-4-5-20251001"
"claude-haiku-4-5-thinking": "claude-haiku-4-5-20251001-thinking"
"claude-opus-4-5": "claude-opus-4-5-20251101"
"claude-opus-4-5-thinking": "claude-opus-4-5-20251101-thinking"
"claude-sonnet-4-5": "claude-sonnet-4-5-20250929"
"claude-sonnet-4-5-thinking": "claude-sonnet-4-5-20250929-thinking"
# Available models (client model names, i.e., keys in model_mappings)
# Only requests for these models will be routed to this upstream
# If not specified, all models are accepted
available_models:
- "claude-haiku-4-5"
- "claude-haiku-4-5-thinking"
- "claude-sonnet-4-5"
- "claude-sonnet-4-5-thinking"
- "claude-opus-4-5"
- "claude-opus-4-5-thinking"
- name: "HotaruAPI"
base_url: "https://api.hotaruapi.top"
token: "sk-"
weight: 5
api_type: "anthropic"
request_compression: "gzip"
model_mappings:
"claude-haiku-4-5": "claude-haiku-4-5-20251001"
"claude-opus-4-5": "claude-opus-4-5-20251101"
"claude-sonnet-4-5": "claude-sonnet-4-5-20250929"
"claude-sonnet-4-5-thinking": "claude-sonnet-4-5-20250929-thinking"
available_models:
- "claude-haiku-4-5"
- "claude-sonnet-4-5"
- "claude-sonnet-4-5-thinking"
- "claude-opus-4-5"
- name: "Huan API"
base_url: "https://ai.huan666.de"
token: "sk-"
weight: 1
api_type: "anthropic"
request_compression: "br"
model_mappings:
"claude-haiku-4-5": "claude-haiku-4-5-20251001"
"claude-sonnet-4-5": "claude-sonnet-4-5-20250929"
available_models:
- "claude-haiku-4-5"
- "claude-sonnet-4-5"
- name: "123nhh"
base_url: "https://new.123nhh.xyz"
token: "sk-"
weight: 1
api_type: "anthropic"
request_compression: "none"
model_mappings:
"claude-opus-4-5-thinking": "gemini-claude-opus-4-5-thinking"
"claude-sonnet-4-5": "gemini-claude-sonnet-4-5"
available_models:
- "claude-opus-4-5-thinking"
- "claude-sonnet-4-5"
- name: "黑与白"
base_url: "https://ai.hybgzs.com/claude"
token: "sk-"
weight: 5
api_type: "anthropic"
available_models:
- "claude-opus-4.6"
- "claude-opus-4.6-think"
- name: "摸鱼公益"
base_url: "https://clove.cc.cd"
token: "sk-"
weight: 5
api_type: "anthropic"
available_models:
- "claude-opus-4.6"
- "claude-sonnet-4.5"
- name: "elysiver"
base_url: "https://elysiver.h-e.top"
token: "sk-"
weight: 5
api_type: "anthropic"
model_mappings:
"claude-sonnet-4-5": "claude-4.5-sonnet-real"
available_models:
- "claude-sonnet-4-5"
- name: "FreeDuckCoding"
base_url: "https://free.duckcoding.com"
token: "sk-"
weight: 5
api_type: "anthropic"
model_mappings:
"claude-sonnet-4-5-thinking": "claude-sonnet-4-5-20250929-thinking"
"claude-sonnet-4-5": "claude-sonnet-4-5-20250929"
"claude-haiku-4-5": "claude-haiku-4-5-20251001"
available_models:
- "claude-haiku-4-5"
- "claude-sonnet-4-5"
- "claude-sonnet-4-5-thinking"
# Example OpenAI-compatible upstream
# Use api_type: "openai" for OpenAI-compatible services
- name: "OpenAI Compatible"
base_url: "https://api.openai.com"
# Multiple tokens: round-robin with automatic failover on 4xx/5xx
token:
- "sk-your-openai-key-1"
- "sk-your-openai-key-2"
weight: 5
enabled: false
api_type: "openai" # Use OpenAI API format (Authorization: Bearer header, /v1/chat/completions endpoint)
model_mappings:
"gpt-4": "gpt-4-turbo"
"gpt-4o": "gpt-4o-2024-11-20"
available_models:
- "gpt-4"
- "gpt-4o"
# Example OpenAI upstream with native Responses API support
# Use api_type: "responses" for native /v1/responses endpoint
- name: "OpenAI Responses"
base_url: "https://api.openai.com"
token: "sk-your-openai-key"
weight: 5
enabled: false
api_type: "responses" # Use native Responses API format (/v1/responses endpoint)
request_compression: "zstd"
model_mappings:
"gpt-4o": "gpt-4o-2024-11-20"
available_models:
- "gpt-4o"
# Example Gemini upstream
# Use api_type: "gemini" for Google Gemini API
- name: "Google Gemini"
base_url: "https://generativelanguage.googleapis.com"
token: "your-gemini-api-key"
weight: 5
enabled: false
api_type: "gemini" # Use Gemini API format (API key auth, /v1beta/models endpoint)
model_mappings:
"gemini-pro": "gemini-1.5-pro"
"gemini-flash": "gemini-1.5-flash"
available_models:
- "gemini-pro"
- "gemini-flash"
# Example Codex upstream (ChatGPT Code Assist with OAuth)
# Use api_type: "codex" for ChatGPT Codex API
- name: "ChatGPT Codex"
weight: 5
enabled: false
api_type: "codex" # Use Codex API format (OAuth, chatgpt.com/backend-api/codex/responses)
# For OAuth-based upstreams, use auth_files instead of token
# Multiple auth files will be used in round-robin fashion
auth_files:
- "/path/to/codex-auth1.json"
- "/path/to/codex-auth2.json"
model_mappings:
"codex-pro": "gpt-4o"
available_models:
- "codex-pro"
# Example Gemini CLI upstream (Google Cloud Code Assist with OAuth)
# Use api_type: "geminicli" for Gemini CLI API
- name: "Gemini CLI"
weight: 5
enabled: false
api_type: "geminicli" # Use Gemini CLI API format (OAuth, cloudcode-pa.googleapis.com)
request_compression: "gzip"
# For OAuth-based upstreams, use auth_files instead of token
auth_files:
- "/path/to/geminicli-auth1.json"
- "/path/to/geminicli-auth2.json"
model_mappings:
"gemini-3-pro": "gemini-3-pro-preview"
"gemini-3-flash": "gemini-3-flash-preview"
available_models:
- "gemini-3-pro"
- "gemini-3-flash"
# Example Antigravity upstream (Google Antigravity with OAuth)
# Use api_type: "antigravity" for Antigravity API
- name: "Antigravity"
weight: 5
enabled: false
api_type: "antigravity" # Use Antigravity API format (OAuth, daily-cloudcode-pa.googleapis.com)
auth_files:
- "/path/to/antigravity-auth1.json"
- "/path/to/antigravity-auth2.json"
model_mappings:
"gemini-3-pro": "gemini-3-pro-high"
"claude-opus-4-6": "claude-opus-4-6-thinking"
available_models:
- "gemini-3-pro"
- "claude-opus-4-6"
# Example Claude Code upstream (Anthropic Claude Code with OAuth)
# Use api_type: "claudecode" for Claude Code API
- name: "Claude Code"
weight: 5
enabled: false
api_type: "claudecode" # Use Claude Code API format (OAuth, api.anthropic.com)
auth_files:
- "/path/to/claudecode-auth1.json"
- "/path/to/claudecode-auth2.json"
model_mappings:
"claude-opus-4-6": "claude-opus-4-6"
"claude-sonnet-4-6": "claude-sonnet-4-6"
available_models:
- "claude-opus-4-6"
- "claude-sonnet-4-6"