-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.py
More file actions
259 lines (258 loc) · 14.3 KB
/
proxy.py
File metadata and controls
259 lines (258 loc) · 14.3 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
from config import Config
PROVIDER_DETAILS = {
'openai': {
'description': 'OpenAI API for GPT models and embeddings',
'endpoints': [
{
'url': '/v1/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/openai/v1/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"gpt-3.5-turbo\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}]}"'
}
]
},
'cerebras': {
'description': 'Cerebras AI models for text generation and chat',
'endpoints': [
{
'url': '/v1/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/cerebras/v1/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"cerebras/btlm-3b-8k\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}]}"'
}
]
},
'googleai': {
'description': 'Google AI with Gemini models for text and multimodal tasks',
'endpoints': [
{
'url': '/predict',
'curl': 'curl -X POST "http://localhost:1400/googleai/predict" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"google/gemini-pro\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}]}"'
}
]
},
'xai': {
'description': 'X.AI (formerly Twitter) language models',
'endpoints': [
{
'url': '/v1/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/xai/v1/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"x-1\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}]}"'
}
]
},
'groq': {
'description': 'Groq API for ultra-fast LLM inference',
'endpoints': [
{
'url': '/openai/v1/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/groq/openai/v1/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"llama3-70b-8192\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}]}"'
}
]
},
'azure': {
'description': 'Azure AI models for text generation and chat',
'endpoints': [
{
'url': '/v1/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/azure/v1/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"gpt-4\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}]}"'
}
]
},
'scaleway': {
'description': 'Scaleway AI models for text generation',
'endpoints': [
{
'url': '/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/scaleway/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"mistral\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}]}"'
}
]
},
'hyperbolic': {
'description': 'Hyperbolic AI models for text generation',
'endpoints': [
{
'url': '/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/hyperbolic/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"mixtral-8x7b\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}]}"'
}
]
},
'sambanova': {
'description': 'SambaNova AI models for text generation and chat',
'endpoints': [
{
'url': '/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/sambanova/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"sambanova-gpt\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}]}"'
},
{
'url': '/completions',
'curl': 'curl -X POST "http://localhost:1400/sambanova/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"sambanova-gpt\\", \\"prompt\\": \\"Hello!\\"}"'
}
],
'supported_features': {
'streaming': True,
'function_calling': False,
'json_mode': False
}
},
'openrouter': {
'description': 'OpenRouter - Gateway to multiple AI models including Anthropic, Meta, Google, and more',
'endpoints': [
{
'url': '/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/openrouter/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -H "HTTP-Referer: $YOUR_SITE_URL" -H "X-Title: $YOUR_APP_NAME" -d "{\\"model\\": \\"openai/gpt-3.5-turbo\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}]}"'
},
{
'url': '/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/openrouter/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"anthropic/claude-2\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}]}"'
},
{
'url': '/models',
'curl': 'curl -X GET "http://localhost:1400/openrouter/models" -H "Authorization: Bearer $API_KEY"'
}
],
'supported_features': {
'streaming': True,
'function_calling': True,
'json_mode': True
}
},
'opencode': {
'description': 'OpenCode Zen Go plan - OpenAI-compatible access to curated models like Kimi K2.6',
'endpoints': [
{
'url': '/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/opencode/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"kimi-k2.6\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}], \\"max_tokens\\": 128}"'
}
],
'supported_features': {
'streaming': True,
'json_mode': True
},
'default_model': 'kimi-k2.6'
},
'mimo': {
'description': 'Xiaomi MiMo Token Plan - OpenAI-compatible access to MiMo-V2.5-Pro',
'endpoints': [
{
'url': '/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/mimo/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"mimo-v2.5-pro\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}], \\"max_tokens\\": 128}"'
}
],
'supported_features': {
'streaming': True,
'function_calling': True,
'json_mode': True
},
'default_model': 'mimo-v2.5-pro'
},
'nineteen': {
'description': 'Nineteen AI - High-performance inference for open-source models',
'endpoints': [
{
'url': '/v1/completions',
'curl': 'curl -X POST "http://localhost:1400/nineteen/v1/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"TheBloke/Rogue-Rose-103b-v0.2-AWQ\\", \\"prompt\\": \\"Hello!\\", \\"temperature\\": 0.5, \\"max_tokens\\": 50, \\"top_p\\": 0.5, \\"stream\\": true}"'
}
],
'supported_features': {
'streaming': True,
'function_calling': False,
'json_mode': False
}
},
'palm': {
'description': 'Google PaLM API for text generation and chat',
'endpoints': [
{
'url': '/models/chat-bison-001/generateText',
'curl': 'curl -X POST "http://localhost:1400/palm/models/chat-bison-001/generateText" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"prompt\\": {\\"messages\\": [{\\"content\\": \\"Hello!\\"}]}}"'
},
{
'url': '/models/text-bison-001/generateText',
'curl': 'curl -X POST "http://localhost:1400/palm/models/text-bison-001/generateText" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"prompt\\": \\"Hello!\\"}"'
},
{
'url': '/models',
'curl': 'curl -X GET "http://localhost:1400/palm/models" -H "Authorization: Bearer $API_KEY"'
}
],
'supported_features': {
'streaming': False,
'function_calling': False,
'json_mode': False
},
'default_model': 'chat-bison-001'
},
'together': {
'description': 'Together AI for high-performance open LLMs',
'endpoints': [
{
'url': '/v1/chat/completions',
'curl': 'curl -X POST "http://localhost:1400/together/v1/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo\\", \\"messages\\": [{\\"role\\": \\"user\\", \\"content\\": \\"Hello!\\"}]}"'
},
{
'url': '/v1/models',
'curl': 'curl -X GET "http://localhost:1400/together/v1/models" -H "Authorization: Bearer $API_KEY"'
},
{
'url': '/v1/completions',
'curl': 'curl -X POST "http://localhost:1400/together/v1/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo\\", \\"prompt\\": \\"Hello!\\"}"'
}
],
'supported_features': {
'streaming': True,
'function_calling': True,
'json_mode': True
},
'default_model': 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo'
},
'chutes': {
'description': 'Chutes AI - Access to DeepSeek and other models',
'endpoints': [
{
'url': '/v1/completions',
'curl': 'curl -X POST "http://localhost:1400/chutes/v1/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\\"model\\": \\"deepseek-ai/DeepSeek-V3\\", \\"prompt\\": \\"Hello!\\", \\"temperature\\": 0.7, \\"max_tokens\\": 100, \\"stream\\": true}"'
}
],
'supported_features': {
'streaming': True,
'function_calling': False,
'json_mode': False
},
'default_model': 'deepseek-ai/DeepSeek-V3'
},
'gemini': {
'description': 'Google Gemini models via Generative Language API',
'endpoints': [
{
'url': '/models/gemini-2.0-flash:generateContent',
'curl': 'curl -X POST "http://localhost:1400/gemini/models/gemini-2.0-flash:generateContent" -H "Content-Type: application/json" -d "{\\"contents\\": [{\\"parts\\":[{\\"text\\": \\"Explain how AI works\\"}]}], \\"safetySettings\\": [{\\"category\\": \\"HARM_CATEGORY_HARASSMENT\\", \\"threshold\\": \\"BLOCK_NONE\\"}, {\\"category\\": \\"HARM_CATEGORY_HATE_SPEECH\\", \\"threshold\\": \\"BLOCK_NONE\\"}, {\\"category\\": \\"HARM_CATEGORY_SEXUALLY_EXPLICIT\\", \\"threshold\\": \\"BLOCK_NONE\\"}, {\\"category\\": \\"HARM_CATEGORY_DANGEROUS_CONTENT\\", \\"threshold\\": \\"BLOCK_NONE\\"}]}"'
},
{
'url': '/models/gemini-2.0-pro:generateContent',
'curl': 'curl -X POST "http://localhost:1400/gemini/models/gemini-2.0-pro:generateContent" -H "Content-Type: application/json" -d "{\\"contents\\": [{\\"parts\\":[{\\"text\\": \\"Explain how AI works\\"}]}], \\"safetySettings\\": [{\\"category\\": \\"HARM_CATEGORY_HARASSMENT\\", \\"threshold\\": \\"BLOCK_NONE\\"}, {\\"category\\": \\"HARM_CATEGORY_HATE_SPEECH\\", \\"threshold\\": \\"BLOCK_NONE\\"}, {\\"category\\": \\"HARM_CATEGORY_SEXUALLY_EXPLICIT\\", \\"threshold\\": \\"BLOCK_NONE\\"}, {\\"category\\": \\"HARM_CATEGORY_DANGEROUS_CONTENT\\", \\"threshold\\": \\"BLOCK_NONE\\"}]}"'
}
],
'supported_features': {
'streaming': True,
'function_calling': True,
'json_mode': True,
'web_search': True # Gemini has web search capability
},
'default_model': 'gemini-2.0-flash'
},
'gemma': {
'description': 'Google Gemma open-source models via Generative Language API',
'endpoints': [
{
'url': '/models/gemma-2-9b:generateContent',
'curl': 'curl -X POST "http://localhost:1400/gemma/models/gemma-2-9b:generateContent" -H "Content-Type: application/json" -d "{\\"contents\\": [{\\"parts\\":[{\\"text\\": \\"Explain how AI works\\"}]}], \\"safetySettings\\": [{\\"category\\": \\"HARM_CATEGORY_HARASSMENT\\", \\"threshold\\": \\"BLOCK_NONE\\"}, {\\"category\\": \\"HARM_CATEGORY_HATE_SPEECH\\", \\"threshold\\": \\"BLOCK_NONE\\"}, {\\"category\\": \\"HARM_CATEGORY_SEXUALLY_EXPLICIT\\", \\"threshold\\": \\"BLOCK_NONE\\"}, {\\"category\\": \\"HARM_CATEGORY_DANGEROUS_CONTENT\\", \\"threshold\\": \\"BLOCK_NONE\\"}]}"'
},
{
'url': '/models/gemma-1.1-7b-it:generateContent',
'curl': 'curl -X POST "http://localhost:1400/gemma/models/gemma-1.1-7b-it:generateContent" -H "Content-Type: application/json" -d "{\\"contents\\": [{\\"parts\\":[{\\"text\\": \\"Explain how AI works\\"}]}], \\"safetySettings\\": [{\\"category\\": \\"HARM_CATEGORY_HARASSMENT\\", \\"threshold\\": \\"BLOCK_NONE\\"}, {\\"category\\": \\"HARM_CATEGORY_HATE_SPEECH\\", \\"threshold\\": \\"BLOCK_NONE\\"}, {\\"category\\": \\"HARM_CATEGORY_SEXUALLY_EXPLICIT\\", \\"threshold\\": \\"BLOCK_NONE\\"}, {\\"category\\": \\"HARM_CATEGORY_DANGEROUS_CONTENT\\", \\"threshold\\": \\"BLOCK_NONE\\"}]}"'
}
],
'supported_features': {
'streaming': True,
'function_calling': True,
'json_mode': True
},
'default_model': 'gemma-2-9b'
}
}