Skip to content

Commit 2ba90bf

Browse files
committed
feat: add SiliconCloud provider support
- Add SiliconCloud provider implementation based on OpenAI-compatible API - Support multiple API endpoints (China, China-overseas, International) - Add model definitions with region-specific pricing - Integrate with UI settings and validation - Add i18n translations for SiliconCloud settings Closes #8550
1 parent 5a3f911 commit 2ba90bf

File tree

12 files changed

+472
-0
lines changed

12 files changed

+472
-0
lines changed

packages/types/src/provider-settings.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
qwenCodeModels,
2222
rooModels,
2323
sambaNovaModels,
24+
siliconCloudModels,
2425
vertexModels,
2526
vscodeLlmModels,
2627
xaiModels,
@@ -135,6 +136,7 @@ export const providerNames = [
135136
"qwen-code",
136137
"roo",
137138
"sambanova",
139+
"siliconcloud",
138140
"vertex",
139141
"xai",
140142
"zai",
@@ -377,6 +379,15 @@ const sambaNovaSchema = apiModelIdProviderModelSchema.extend({
377379
sambaNovaApiKey: z.string().optional(),
378380
})
379381

382+
export const siliconCloudApiLineSchema = z.enum(["china", "china-overseas", "international"])
383+
384+
export type SiliconCloudApiLine = z.infer<typeof siliconCloudApiLineSchema>
385+
386+
const siliconCloudSchema = apiModelIdProviderModelSchema.extend({
387+
siliconCloudApiKey: z.string().optional(),
388+
siliconCloudApiLine: siliconCloudApiLineSchema.optional(),
389+
})
390+
380391
export const zaiApiLineSchema = z.enum(["international_coding", "international", "china_coding", "china"])
381392

382393
export type ZaiApiLine = z.infer<typeof zaiApiLineSchema>
@@ -446,6 +457,7 @@ export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProv
446457
litellmSchema.merge(z.object({ apiProvider: z.literal("litellm") })),
447458
cerebrasSchema.merge(z.object({ apiProvider: z.literal("cerebras") })),
448459
sambaNovaSchema.merge(z.object({ apiProvider: z.literal("sambanova") })),
460+
siliconCloudSchema.merge(z.object({ apiProvider: z.literal("siliconcloud") })),
449461
zaiSchema.merge(z.object({ apiProvider: z.literal("zai") })),
450462
fireworksSchema.merge(z.object({ apiProvider: z.literal("fireworks") })),
451463
featherlessSchema.merge(z.object({ apiProvider: z.literal("featherless") })),
@@ -487,6 +499,7 @@ export const providerSettingsSchema = z.object({
487499
...litellmSchema.shape,
488500
...cerebrasSchema.shape,
489501
...sambaNovaSchema.shape,
502+
...siliconCloudSchema.shape,
490503
...zaiSchema.shape,
491504
...fireworksSchema.shape,
492505
...featherlessSchema.shape,
@@ -573,6 +586,7 @@ export const modelIdKeysByProvider: Record<TypicalProvider, ModelIdKey> = {
573586
huggingface: "huggingFaceModelId",
574587
cerebras: "apiModelId",
575588
sambanova: "apiModelId",
589+
siliconcloud: "apiModelId",
576590
zai: "apiModelId",
577591
fireworks: "apiModelId",
578592
featherless: "apiModelId",
@@ -683,6 +697,7 @@ export const MODELS_BY_PROVIDER: Record<
683697
label: "SambaNova",
684698
models: Object.keys(sambaNovaModels),
685699
},
700+
siliconcloud: { id: "siliconcloud", label: "SiliconCloud", models: Object.keys(siliconCloudModels) },
686701
vertex: {
687702
id: "vertex",
688703
label: "GCP Vertex AI",

packages/types/src/providers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export * from "./qwen-code.js"
2323
export * from "./requesty.js"
2424
export * from "./roo.js"
2525
export * from "./sambanova.js"
26+
export * from "./siliconcloud.js"
2627
export * from "./unbound.js"
2728
export * from "./vertex.js"
2829
export * from "./vscode-llm.js"
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
import type { ModelInfo } from "../model.js"
2+
import type { SiliconCloudApiLine } from "../provider-settings.js"
3+
4+
export const siliconCloudDefaultModelId = "zai-org/GLM-4.6"
5+
6+
export const siliconCloudApiLineConfigs = {
7+
china: { name: "国内版", baseUrl: "https://api.siliconflow.cn/v1" },
8+
"china-overseas": { name: "国内版(海外访问)", baseUrl: "https://api-st.siliconflow.cn/v1" },
9+
international: { name: "国际版", baseUrl: "https://api.siliconflow.com/v1" },
10+
} satisfies Record<SiliconCloudApiLine, { name: string; baseUrl: string }>
11+
12+
const siliconCloudChinaModels: Record<string, ModelInfo> = {
13+
"Pro/deepseek-ai/DeepSeek-V3.1-Terminus": {
14+
contextWindow: 163840,
15+
maxTokens: 8192,
16+
supportsImages: false,
17+
supportsPromptCache: false,
18+
inputPrice: 0.14,
19+
outputPrice: 0.28,
20+
supportsReasoningBudget: true,
21+
},
22+
"zai-org/GLM-4.6": {
23+
contextWindow: 131072,
24+
maxTokens: 8192,
25+
supportsImages: false,
26+
supportsPromptCache: false,
27+
inputPrice: 0,
28+
outputPrice: 0,
29+
supportsReasoningBudget: true,
30+
},
31+
"Qwen/QwQ-32B-Preview": {
32+
contextWindow: 32768,
33+
maxTokens: 32768,
34+
supportsImages: false,
35+
supportsPromptCache: false,
36+
inputPrice: 0,
37+
outputPrice: 0,
38+
supportsReasoningBudget: true,
39+
},
40+
"Qwen/Qwen2.5-Coder-32B-Instruct": {
41+
contextWindow: 131072,
42+
maxTokens: 8192,
43+
supportsImages: false,
44+
supportsPromptCache: false,
45+
inputPrice: 0,
46+
outputPrice: 0,
47+
},
48+
"deepseek-ai/DeepSeek-V2.5": {
49+
contextWindow: 131072,
50+
maxTokens: 8192,
51+
supportsImages: false,
52+
supportsPromptCache: false,
53+
inputPrice: 0.14,
54+
outputPrice: 0.28,
55+
},
56+
"deepseek-ai/DeepSeek-Coder-V2-Instruct": {
57+
contextWindow: 131072,
58+
maxTokens: 8192,
59+
supportsImages: false,
60+
supportsPromptCache: false,
61+
inputPrice: 0.14,
62+
outputPrice: 0.28,
63+
},
64+
"Qwen/Qwen2.5-72B-Instruct": {
65+
contextWindow: 131072,
66+
maxTokens: 8192,
67+
supportsImages: false,
68+
supportsPromptCache: false,
69+
inputPrice: 0.35,
70+
outputPrice: 1.4,
71+
},
72+
"meta-llama/Meta-Llama-3.1-70B-Instruct": {
73+
contextWindow: 131072,
74+
maxTokens: 8192,
75+
supportsImages: false,
76+
supportsPromptCache: false,
77+
inputPrice: 0.35,
78+
outputPrice: 0.42,
79+
},
80+
"meta-llama/Meta-Llama-3.1-405B-Instruct": {
81+
contextWindow: 131072,
82+
maxTokens: 8192,
83+
supportsImages: false,
84+
supportsPromptCache: false,
85+
inputPrice: 2.1,
86+
outputPrice: 2.1,
87+
},
88+
"google/gemma-2-27b-it": {
89+
contextWindow: 8192,
90+
maxTokens: 8192,
91+
supportsImages: false,
92+
supportsPromptCache: false,
93+
inputPrice: 0.14,
94+
outputPrice: 0.28,
95+
},
96+
"01-ai/Yi-1.5-34B-Chat-16K": {
97+
contextWindow: 16384,
98+
maxTokens: 4096,
99+
supportsImages: false,
100+
supportsPromptCache: false,
101+
inputPrice: 0.14,
102+
outputPrice: 0.84,
103+
},
104+
"internlm/internlm2_5-20b-chat": {
105+
contextWindow: 32768,
106+
maxTokens: 8192,
107+
supportsImages: false,
108+
supportsPromptCache: false,
109+
inputPrice: 0.14,
110+
outputPrice: 0.28,
111+
},
112+
}
113+
114+
const siliconCloudChinaOverseasModels: Record<string, ModelInfo> = {
115+
...siliconCloudChinaModels,
116+
}
117+
118+
const siliconCloudInternationalModels: Record<string, ModelInfo> = {
119+
"Pro/deepseek-ai/DeepSeek-V3.1-Terminus": {
120+
contextWindow: 163840,
121+
maxTokens: 8192,
122+
supportsImages: false,
123+
supportsPromptCache: false,
124+
inputPrice: 0.02,
125+
outputPrice: 0.04,
126+
supportsReasoningBudget: true,
127+
},
128+
"zai-org/GLM-4.6": {
129+
contextWindow: 131072,
130+
maxTokens: 8192,
131+
supportsImages: false,
132+
supportsPromptCache: false,
133+
inputPrice: 0,
134+
outputPrice: 0,
135+
supportsReasoningBudget: true,
136+
},
137+
"Qwen/QwQ-32B-Preview": {
138+
contextWindow: 32768,
139+
maxTokens: 32768,
140+
supportsImages: false,
141+
supportsPromptCache: false,
142+
inputPrice: 0,
143+
outputPrice: 0,
144+
supportsReasoningBudget: true,
145+
},
146+
"Qwen/Qwen2.5-Coder-32B-Instruct": {
147+
contextWindow: 131072,
148+
maxTokens: 8192,
149+
supportsImages: false,
150+
supportsPromptCache: false,
151+
inputPrice: 0,
152+
outputPrice: 0,
153+
},
154+
"deepseek-ai/DeepSeek-V2.5": {
155+
contextWindow: 131072,
156+
maxTokens: 8192,
157+
supportsImages: false,
158+
supportsPromptCache: false,
159+
inputPrice: 0.02,
160+
outputPrice: 0.04,
161+
},
162+
"deepseek-ai/DeepSeek-Coder-V2-Instruct": {
163+
contextWindow: 131072,
164+
maxTokens: 8192,
165+
supportsImages: false,
166+
supportsPromptCache: false,
167+
inputPrice: 0.02,
168+
outputPrice: 0.04,
169+
},
170+
"Qwen/Qwen2.5-72B-Instruct": {
171+
contextWindow: 131072,
172+
maxTokens: 8192,
173+
supportsImages: false,
174+
supportsPromptCache: false,
175+
inputPrice: 0.05,
176+
outputPrice: 0.2,
177+
},
178+
"meta-llama/Meta-Llama-3.1-70B-Instruct": {
179+
contextWindow: 131072,
180+
maxTokens: 8192,
181+
supportsImages: false,
182+
supportsPromptCache: false,
183+
inputPrice: 0.05,
184+
outputPrice: 0.06,
185+
},
186+
"meta-llama/Meta-Llama-3.1-405B-Instruct": {
187+
contextWindow: 131072,
188+
maxTokens: 8192,
189+
supportsImages: false,
190+
supportsPromptCache: false,
191+
inputPrice: 0.3,
192+
outputPrice: 0.3,
193+
},
194+
"google/gemma-2-27b-it": {
195+
contextWindow: 8192,
196+
maxTokens: 8192,
197+
supportsImages: false,
198+
supportsPromptCache: false,
199+
inputPrice: 0.02,
200+
outputPrice: 0.04,
201+
},
202+
"01-ai/Yi-1.5-34B-Chat-16K": {
203+
contextWindow: 16384,
204+
maxTokens: 4096,
205+
supportsImages: false,
206+
supportsPromptCache: false,
207+
inputPrice: 0.02,
208+
outputPrice: 0.12,
209+
},
210+
"internlm/internlm2_5-20b-chat": {
211+
contextWindow: 32768,
212+
maxTokens: 8192,
213+
supportsImages: false,
214+
supportsPromptCache: false,
215+
inputPrice: 0.02,
216+
outputPrice: 0.04,
217+
},
218+
}
219+
220+
export const siliconCloudModelsByApiLine = {
221+
china: siliconCloudChinaModels,
222+
"china-overseas": siliconCloudChinaOverseasModels,
223+
international: siliconCloudInternationalModels,
224+
} satisfies Record<SiliconCloudApiLine, Record<string, ModelInfo>>
225+
226+
// Export all models for the default list
227+
export const siliconCloudModels = siliconCloudChinaModels
228+
229+
export type SiliconCloudModelId = keyof typeof siliconCloudModels

src/api/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
ClaudeCodeHandler,
3333
QwenCodeHandler,
3434
SambaNovaHandler,
35+
SiliconCloudHandler,
3536
IOIntelligenceHandler,
3637
DoubaoHandler,
3738
ZAiHandler,
@@ -151,6 +152,8 @@ export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
151152
return new CerebrasHandler(options)
152153
case "sambanova":
153154
return new SambaNovaHandler(options)
155+
case "siliconcloud":
156+
return new SiliconCloudHandler(options)
154157
case "zai":
155158
return new ZAiHandler(options)
156159
case "fireworks":

src/api/providers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export { OpenRouterHandler } from "./openrouter"
2424
export { QwenCodeHandler } from "./qwen-code"
2525
export { RequestyHandler } from "./requesty"
2626
export { SambaNovaHandler } from "./sambanova"
27+
export { SiliconCloudHandler } from "./siliconcloud"
2728
export { UnboundHandler } from "./unbound"
2829
export { VertexHandler } from "./vertex"
2930
export { VsCodeLmHandler } from "./vscode-lm"

0 commit comments

Comments
 (0)