Skip to content
This repository was archived by the owner on Jan 24, 2026. It is now read-only.

Commit bef0b6b

Browse files
authored
Merge pull request #5 from Stream29/feat/open-router-support
feat(server): add OpenRouter support
2 parents 36707d1 + bfe9520 commit bef0b6b

File tree

4 files changed

+371
-1
lines changed

4 files changed

+371
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ apiProviders:
107107
- Qwen/Qwen3-235B-A22B
108108
- Pro/deepseek-ai/DeepSeek-V3
109109
- THUDM/GLM-4-32B-0414
110+
OpenRouter:
111+
type: OpenRouter
112+
apiKey: <your_api_key>
113+
modelList:
114+
- openai/gpt-4o
110115
Gemini:
111116
type: Gemini
112117
apiKey: <your_api_key>

config_v4.schema.json

Lines changed: 353 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,353 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"lmStudio": {
5+
"type": "object",
6+
"properties": {
7+
"port": {
8+
"type": "integer",
9+
"minimum": -2147483648,
10+
"maximum": 2147483647
11+
},
12+
"host": {
13+
"type": "string"
14+
},
15+
"path": {
16+
"type": "string"
17+
},
18+
"enabled": {
19+
"type": "boolean"
20+
}
21+
}
22+
},
23+
"ollama": {
24+
"type": "object",
25+
"properties": {
26+
"port": {
27+
"type": "integer",
28+
"minimum": -2147483648,
29+
"maximum": 2147483647
30+
},
31+
"host": {
32+
"type": "string"
33+
},
34+
"path": {
35+
"type": "string"
36+
},
37+
"enabled": {
38+
"type": "boolean"
39+
}
40+
}
41+
},
42+
"client": {
43+
"type": "object",
44+
"properties": {
45+
"socketTimeout": {
46+
"type": "integer"
47+
},
48+
"connectTimeout": {
49+
"type": "integer"
50+
},
51+
"requestTimeout": {
52+
"type": "integer"
53+
},
54+
"retry": {
55+
"type": "integer",
56+
"minimum": -2147483648,
57+
"maximum": 2147483647
58+
},
59+
"delayBeforeRetry": {
60+
"type": "integer"
61+
}
62+
}
63+
},
64+
"apiProviders": {
65+
"type": "object",
66+
"additionalProperties": {
67+
"$ref": "#/$defs/ApiProvider"
68+
}
69+
}
70+
},
71+
"$defs": {
72+
"ApiProvider": {
73+
"anyOf": [
74+
{
75+
"allOf": [
76+
{
77+
"type": "object",
78+
"properties": {
79+
"apiKey": {
80+
"type": "string"
81+
},
82+
"modelList": {
83+
"type": "array",
84+
"items": {
85+
"type": "string"
86+
}
87+
}
88+
},
89+
"required": [
90+
"apiKey",
91+
"modelList"
92+
]
93+
},
94+
{
95+
"properties": {
96+
"type": {
97+
"enum": [
98+
"Claude"
99+
]
100+
}
101+
},
102+
"required": [
103+
"type"
104+
]
105+
}
106+
]
107+
},
108+
{
109+
"allOf": [
110+
{
111+
"type": "object",
112+
"properties": {
113+
"apiKey": {
114+
"type": "string"
115+
},
116+
"modelList": {
117+
"type": "array",
118+
"items": {
119+
"type": "string"
120+
}
121+
}
122+
},
123+
"required": [
124+
"apiKey"
125+
]
126+
},
127+
{
128+
"properties": {
129+
"type": {
130+
"enum": [
131+
"DashScope"
132+
]
133+
}
134+
},
135+
"required": [
136+
"type"
137+
]
138+
}
139+
]
140+
},
141+
{
142+
"allOf": [
143+
{
144+
"type": "object",
145+
"properties": {
146+
"apiKey": {
147+
"type": "string"
148+
},
149+
"modelList": {
150+
"type": "array",
151+
"items": {
152+
"type": "string"
153+
}
154+
}
155+
},
156+
"required": [
157+
"apiKey"
158+
]
159+
},
160+
{
161+
"properties": {
162+
"type": {
163+
"enum": [
164+
"DeepSeek"
165+
]
166+
}
167+
},
168+
"required": [
169+
"type"
170+
]
171+
}
172+
]
173+
},
174+
{
175+
"allOf": [
176+
{
177+
"type": "object",
178+
"properties": {
179+
"apiKey": {
180+
"type": "string"
181+
},
182+
"modelList": {
183+
"type": "array",
184+
"items": {
185+
"type": "string"
186+
}
187+
}
188+
},
189+
"required": [
190+
"apiKey",
191+
"modelList"
192+
]
193+
},
194+
{
195+
"properties": {
196+
"type": {
197+
"enum": [
198+
"Gemini"
199+
]
200+
}
201+
},
202+
"required": [
203+
"type"
204+
]
205+
}
206+
]
207+
},
208+
{
209+
"allOf": [
210+
{
211+
"type": "object",
212+
"properties": {
213+
"apiKey": {
214+
"type": "string"
215+
},
216+
"modelList": {
217+
"type": "array",
218+
"items": {
219+
"type": "string"
220+
}
221+
}
222+
},
223+
"required": [
224+
"apiKey"
225+
]
226+
},
227+
{
228+
"properties": {
229+
"type": {
230+
"enum": [
231+
"Mistral"
232+
]
233+
}
234+
},
235+
"required": [
236+
"type"
237+
]
238+
}
239+
]
240+
},
241+
{
242+
"allOf": [
243+
{
244+
"type": "object",
245+
"properties": {
246+
"baseUrl": {
247+
"type": "string"
248+
},
249+
"apiKey": {
250+
"type": "string"
251+
},
252+
"modelList": {
253+
"type": "array",
254+
"items": {
255+
"type": "string"
256+
}
257+
},
258+
"extraRequest": {
259+
"anyOf": []
260+
}
261+
},
262+
"required": [
263+
"baseUrl",
264+
"apiKey",
265+
"modelList"
266+
]
267+
},
268+
{
269+
"properties": {
270+
"type": {
271+
"enum": [
272+
"OpenAi"
273+
]
274+
}
275+
},
276+
"required": [
277+
"type"
278+
]
279+
}
280+
]
281+
},
282+
{
283+
"allOf": [
284+
{
285+
"type": "object",
286+
"properties": {
287+
"apiKey": {
288+
"type": "string"
289+
},
290+
"modelList": {
291+
"type": "array",
292+
"items": {
293+
"type": "string"
294+
}
295+
}
296+
},
297+
"required": [
298+
"apiKey",
299+
"modelList"
300+
]
301+
},
302+
{
303+
"properties": {
304+
"type": {
305+
"enum": [
306+
"OpenRouter"
307+
]
308+
}
309+
},
310+
"required": [
311+
"type"
312+
]
313+
}
314+
]
315+
},
316+
{
317+
"allOf": [
318+
{
319+
"type": "object",
320+
"properties": {
321+
"apiKey": {
322+
"type": "string"
323+
},
324+
"modelList": {
325+
"type": "array",
326+
"items": {
327+
"type": "string"
328+
}
329+
}
330+
},
331+
"required": [
332+
"apiKey",
333+
"modelList"
334+
]
335+
},
336+
{
337+
"properties": {
338+
"type": {
339+
"enum": [
340+
"SiliconFlow"
341+
]
342+
}
343+
},
344+
"required": [
345+
"type"
346+
]
347+
}
348+
]
349+
}
350+
]
351+
}
352+
}
353+
}

src/main/kotlin/io/github/stream29/proxy/Global.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ val unused = {
5656
helpLogger.info("A default config file is created at ${configFile.absolutePath} with schema annotation.")
5757
configFile.writeText(
5858
"""
59-
# ${'$'}schema: https://github.com/Stream29/ProxyAsLocalModel/raw/master/config_v2.schema.json
59+
# ${'$'}schema: https://github.com/Stream29/ProxyAsLocalModel/raw/master/config_v4.schema.json
6060
lmStudio:
6161
port: 1234
6262
ollama:

src/main/kotlin/io/github/stream29/proxy/client/OpenAiBased.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,16 @@ data class ClaudeConfig(
7373
baseUrl = "https://api.anthropic.com/v1/",
7474
apiKey = apiKey,
7575
modelList = modelList
76+
)
77+
78+
@Suppress("unused")
79+
@Serializable
80+
@SerialName("OpenRouter")
81+
data class OpenRouterConfig(
82+
val apiKey: String,
83+
val modelList: List<String>,
84+
): ApiProvider by OpenAiConfig(
85+
baseUrl = "https://openrouter.ai/api/v1",
86+
apiKey = apiKey,
87+
modelList = modelList
7688
)

0 commit comments

Comments
 (0)