Skip to content

Commit a2c1fe6

Browse files
authored
feat: model updates and + z.ai (#10638)
* Add latest model definitions across providers Add new models for OpenAI (gpt-4.1, gpt-5.2, codex-mini, o1/o3/o4-mini), Gemini (2.5 stable, 2.5-flash-lite, 3-flash-preview), Mistral (devstral, magistral, ministral, mistral-nemo), xAI (grok-4-fast, grok-4-1-fast, grok-3-fast), and Bedrock (Claude 4.5/4.6, Nova, Llama 4, DeepSeek). Update tool support and reasoning detection for the new model families. * Add Z.ai (GLM) provider, Kimi K2/K2.5 models, and fix OpenRouter tool support bug - Add Z.ai as a new provider with GLM-5, GLM-4.7, GLM-4-plus, GLM-4.5 models - Add Kimi K2 and K2.5 model packages to Moonshot provider - Fix variable shadowing bug in OpenRouter tool support where loop variables shadowed the outer model parameter, causing specificModels and supportedContains checks to always return true - Add moonshotai/kimi and zai-org/glm to OpenRouter supported prefixes - Add Z.ai and Moonshot to docs navigation * Clean up unnecessary import aliases for zAI * Add Z.ai Coding Plan endpoint note to docs * Replace placeholder zai.png icon with proper zAI.svg * Add zAI provider to openai-adapters * Fix Z.ai API key URL
1 parent 785a776 commit a2c1fe6

19 files changed

Lines changed: 997 additions & 35 deletions

File tree

core/llm/autodetect.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const PROVIDER_HANDLES_TEMPLATING: string[] = [
7171
"gemini",
7272
"docker",
7373
"nous",
74+
"zAI",
7475
// TODO add these, change to inverted logic so only the ones that need templating are hardcoded
7576
// Asksage.ts
7677
// Azure.ts
@@ -128,6 +129,7 @@ const PROVIDER_SUPPORTS_IMAGES: string[] = [
128129
"nebius",
129130
"ovhcloud",
130131
"watsonx",
132+
"zAI",
131133
];
132134

133135
const MODEL_SUPPORTS_IMAGES: RegExp[] = [
@@ -209,6 +211,19 @@ function modelSupportsReasoning(
209211
if (model.model.includes("deepseek-r")) {
210212
return true;
211213
}
214+
// o-series reasoning models
215+
if (/^o[134]/.test(model.model)) {
216+
return true;
217+
}
218+
if (model.model.includes("codex")) {
219+
return true;
220+
}
221+
if (model.model.includes("magistral")) {
222+
return true;
223+
}
224+
if (model.model.includes("grok-4")) {
225+
return true;
226+
}
212227

213228
return false;
214229
}
@@ -257,6 +272,7 @@ function isProviderHandlesTemplatingOrNoTemplateTypeRequired(
257272
modelName.includes("moonshot") ||
258273
modelName.includes("kimi") ||
259274
modelName.includes("mercury") ||
275+
modelName.includes("glm") ||
260276
/^o\d/.test(modelName)
261277
);
262278
}

core/llm/llms/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import Vllm from "./Vllm";
6767
import Voyage from "./Voyage";
6868
import WatsonX from "./WatsonX";
6969
import xAI from "./xAI";
70+
import zAI from "./zAI";
7071
export const LLMClasses = [
7172
Anthropic,
7273
Cohere,
@@ -126,6 +127,7 @@ export const LLMClasses = [
126127
Voyage,
127128
LlamaStack,
128129
TARS,
130+
zAI,
129131
];
130132

131133
export async function llmFromDescription(

core/llm/llms/zAI.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { LLMOptions } from "../../index.js";
2+
3+
import OpenAI from "./OpenAI.js";
4+
5+
class zAI extends OpenAI {
6+
static providerName = "zAI";
7+
static defaultOptions: Partial<LLMOptions> = {
8+
apiBase: "https://api.z.ai/api/paas/v4/",
9+
useLegacyCompletionsEndpoint: false,
10+
};
11+
}
12+
13+
export default zAI;

core/llm/toolSupport.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
4141
if (
4242
lower.startsWith("gpt-4") ||
4343
lower.startsWith("gpt-5") ||
44-
lower.startsWith("o3")
44+
lower.startsWith("o1") ||
45+
lower.startsWith("o3") ||
46+
lower.startsWith("o4") ||
47+
lower.startsWith("codex") ||
48+
lower.startsWith("gpt-4.1")
4549
) {
4650
return true;
4751
}
@@ -114,6 +118,9 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
114118
"nova-micro",
115119
"nova-premier",
116120
"gpt-oss",
121+
"llama4",
122+
"llama-4",
123+
"deepseek",
117124
].some((part) => model.toLowerCase().includes(part))
118125
) {
119126
return true;
@@ -133,7 +140,7 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
133140
"pixtral",
134141
"ministral",
135142
"mistral-nemo",
136-
"devstral",
143+
"magistral",
137144
].some((part) => model.toLowerCase().includes(part))
138145
);
139146
},
@@ -287,9 +294,11 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
287294
const supportedPrefixes = [
288295
"openai/gpt-3.5",
289296
"openai/gpt-4",
297+
"openai/gpt-5",
290298
"openai/o1",
291299
"openai/o3",
292300
"openai/o4",
301+
"openai/codex",
293302
"openai/gpt-oss",
294303
"anthropic/claude",
295304
"microsoft/phi-3",
@@ -316,6 +325,8 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
316325
"meta-llama/llama-4",
317326
"all-hands/openhands-lm-32b",
318327
"lgai-exaone/exaone",
328+
"moonshotai/kimi",
329+
"zai-org/glm",
319330
];
320331
for (const prefix of supportedPrefixes) {
321332
if (model.toLowerCase().startsWith(prefix)) {
@@ -333,21 +344,25 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
333344
"nousresearch/hermes-3-llama-3.1-70b",
334345
"moonshotai/kimi-k2",
335346
];
336-
for (const model of specificModels) {
337-
if (model.toLowerCase() === model) {
347+
for (const specificModel of specificModels) {
348+
if (model.toLowerCase() === specificModel) {
338349
return true;
339350
}
340351
}
341352

342353
const supportedContains = ["llama-3.1"];
343-
for (const model of supportedContains) {
344-
if (model.toLowerCase().includes(model)) {
354+
for (const contained of supportedContains) {
355+
if (model.toLowerCase().includes(contained)) {
345356
return true;
346357
}
347358
}
348359

349360
return false;
350361
},
362+
zAI: (model) => {
363+
const lower = model.toLowerCase();
364+
return lower.startsWith("glm-4") || lower.startsWith("glm-5");
365+
},
351366
moonshot: (model) => {
352367
// support moonshot models
353368
// https://platform.moonshot.ai/docs/pricing/chat#concepts
@@ -426,7 +441,9 @@ export function isRecommendedAgentModel(modelName: string): boolean {
426441
[/deepseek/, /r1|reasoner/],
427442
[/gemini/, /2\.5/, /pro/],
428443
[/gemini/, /3-pro/],
429-
[/gpt/, /-5|5\.1/],
444+
[/gpt/, /-5|5\.1|5\.2/],
445+
[/gpt-4\.1/],
446+
[/codex/],
430447
[/claude/, /sonnet/, /3\.7|3-7|-4/],
431448
[/claude/, /opus/, /-4/],
432449
[/grok-code/],

docs/customize/model-providers/more/moonshot.mdx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: "Moonshot AI"
3-
description: "Configure Moonshot AI's language models with Continue, including setup instructions for their 8K, 32K, and 128K context window models with competitive pricing"
3+
description: "Configure Moonshot AI's language models with Continue, including Kimi K2, Kimi K2.5, and Moonshot v1 models with competitive pricing"
44
---
55

6-
[Moonshot AI](https://platform.moonshot.cn/) provides high-quality large language model services with competitive pricing and excellent performance.
6+
[Moonshot AI](https://platform.moonshot.cn/) provides high-quality large language model services with competitive pricing and excellent performance, including the Kimi series of models.
77

88
## Configuration
99

@@ -20,20 +20,20 @@ To use Moonshot AI models, you need to:
2020
schema: v1
2121

2222
models:
23-
- name: Moonshot
23+
- name: Kimi K2
2424
provider: moonshot
25-
model: moonshot-v1-8k
25+
model: kimi-k2
2626
apiKey: <YOUR_MOONSHOT_API_KEY>
2727
```
2828
</Tab>
29-
<Tab title="JSON">
29+
<Tab title="JSON (Deprecated)">
3030
```json title="config.json"
3131
{
3232
"models": [
3333
{
34-
"title": "Moonshot",
34+
"title": "Kimi K2",
3535
"provider": "moonshot",
36-
"model": "moonshot-v1-8k",
36+
"model": "kimi-k2",
3737
"apiKey": "<YOUR_MOONSHOT_API_KEY>"
3838
}
3939
]
@@ -46,6 +46,8 @@ To use Moonshot AI models, you need to:
4646

4747
Moonshot AI currently provides the following models:
4848

49+
- `kimi-k2`: Kimi K2, a powerful MoE model with 128K context window
50+
- `kimi-k2.5`: Kimi K2.5, the latest generation with enhanced reasoning and 128K context window
4951
- `moonshot-v1-8k`: Base model with 8K context window
5052
- `moonshot-v1-32k`: Base model with 32K context window
5153
- `moonshot-v1-128k`: Base model with 128K context window
@@ -70,24 +72,24 @@ Here's a complete configuration example:
7072
schema: v1
7173

7274
models:
73-
- name: Moonshot-8K
75+
- name: Kimi K2
7476
provider: moonshot
75-
model: moonshot-v1-8k
77+
model: kimi-k2
7678
apiKey: <YOUR_MOONSHOT_API_KEY>
7779
defaultCompletionOptions:
7880
temperature: 0.7
7981
topP: 0.95
8082
maxTokens: 2048
8183
```
8284
</Tab>
83-
<Tab title="JSON">
85+
<Tab title="JSON (Deprecated)">
8486
```json title="config.json"
8587
{
8688
"models": [
8789
{
88-
"title": "Moonshot-8K",
90+
"title": "Kimi K2",
8991
"provider": "moonshot",
90-
"model": "moonshot-v1-8k",
92+
"model": "kimi-k2",
9193
"apiKey": "<YOUR_MOONSHOT_API_KEY>",
9294
"completionOptions": {
9395
"temperature": 0.7,
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: "Z.ai"
3+
description: "Configure Z.ai's GLM models with Continue, including GLM-5, GLM-4.7, and GLM-4.5"
4+
---
5+
6+
[Z.ai](https://z.ai/) (formerly Zhipu AI) provides the GLM family of large language models with strong multilingual capabilities.
7+
8+
<Info>Get an API key from the [Z.ai Platform](https://z.ai/manage-apikey/apikey-list)</Info>
9+
10+
## Configuration
11+
12+
<Tabs>
13+
<Tab title="YAML">
14+
```yaml title="config.yaml"
15+
name: My Config
16+
version: 0.0.1
17+
schema: v1
18+
19+
models:
20+
- name: GLM-5
21+
provider: zAI
22+
model: glm-5
23+
apiKey: <YOUR_ZAI_API_KEY>
24+
```
25+
</Tab>
26+
<Tab title="JSON (Deprecated)">
27+
```json title="config.json"
28+
{
29+
"models": [
30+
{
31+
"title": "GLM-5",
32+
"provider": "zAI",
33+
"model": "glm-5",
34+
"apiKey": "<YOUR_ZAI_API_KEY>"
35+
}
36+
]
37+
}
38+
```
39+
</Tab>
40+
</Tabs>
41+
42+
## Available Models
43+
44+
- `glm-5`: Flagship model with 128K context window
45+
- `glm-4.7`: Latest generation model with 128K context window
46+
- `glm-4-plus`: Enhanced GLM-4 model with 128K context window
47+
- `glm-4.5`: GLM-4.5 model with 128K context window
48+
49+
## Configuration Options
50+
51+
| Option | Description | Default |
52+
| --------- | -------------------- | -------------------------------------- |
53+
| `apiKey` | Z.ai API key | Required |
54+
| `apiBase` | API base URL | `https://api.z.ai/api/paas/v4/` |
55+
| `model` | Model name to use | `glm-5` |
56+
57+
<Tip>
58+
Z.ai offers a dedicated [Coding Plan](https://docs.z.ai/api-reference/introduction) with a subscription-based endpoint optimized for coding tasks. To use it, set `apiBase` to `https://api.z.ai/api/coding/paas/v4/`. This endpoint uses prompt-based pricing rather than token-based pricing and may be more cost-effective for coding workflows.
59+
</Tip>

docs/docs.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,12 @@
176176
"customize/model-providers/more/llamastack",
177177
"customize/model-providers/more/mimo",
178178
"customize/model-providers/more/mistral",
179+
"customize/model-providers/more/moonshot",
179180
"customize/model-providers/more/nous",
180181
"customize/model-providers/more/nvidia",
181182
"customize/model-providers/more/together",
182-
"customize/model-providers/more/xAI"
183+
"customize/model-providers/more/xAI",
184+
"customize/model-providers/more/zai"
183185
]
184186
}
185187
]

0 commit comments

Comments
 (0)