Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat: add GLM-5.1 model support for Zhipu provider (#13757)

YuTengjing406cb5554bc3
diff --git a/packages/model-bank/src/aiModels/lobehub/chat/zhipu.ts b/packages/model-bank/src/aiModels/lobehub/chat/zhipu.ts
index e5fb3cb58bb..e74916bb46d 100644
--- a/packages/model-bank/src/aiModels/lobehub/chat/zhipu.ts
+++ b/packages/model-bank/src/aiModels/lobehub/chat/zhipu.ts
@@ -1,6 +1,36 @@
import type { AIChatModelCard } from '../../../types/aiModel';
+// price: https://docs.z.ai/guides/overview/pricing
+// ref: https://docs.z.ai/guides/llm/glm-5.1
+
export const zhipuChatModels: AIChatModelCard[] = [
+ {
+ abilities: {
+ functionCall: true,
+ reasoning: true,
+ search: true,
+ },
+ contextWindowTokens: 200_000,
+ description:
+ "Zai's latest flagship model, aligned with Claude Opus 4.6 on overall and coding capabilities. Excels at long-horizon tasks with autonomous work up to 8 hours, an ideal foundation for Autonomous Agents and long-horizon Coding Agents.",
+ displayName: 'GLM-5.1',
+ enabled: true,
+ id: 'glm-5.1',
+ maxOutput: 131_072,
+ pricing: {
+ units: [
+ { name: 'textInput', rate: 1.4, strategy: 'fixed', unit: 'millionTokens' },
+ { name: 'textInput_cacheRead', rate: 0.26, strategy: 'fixed', unit: 'millionTokens' },
+ { name: 'textOutput', rate: 4.4, strategy: 'fixed', unit: 'millionTokens' },
+ ],
+ },
+ releasedAt: '2026-03-27',
+ settings: {
+ extendParams: ['enableReasoning'],
+ searchImpl: 'params',
+ },
+ type: 'chat',
+ },
{
abilities: {
functionCall: true,
diff --git a/packages/model-bank/src/aiModels/zhipu.ts b/packages/model-bank/src/aiModels/zhipu.ts
index bc7eacadfd2..27daefb561c 100644
--- a/packages/model-bank/src/aiModels/zhipu.ts
+++ b/packages/model-bank/src/aiModels/zhipu.ts
@@ -8,6 +8,67 @@ import {
// ref: https://docs.bigmodel.cn/cn/guide/start/model-overview
const zhipuChatModels: AIChatModelCard[] = [
+ {
+ abilities: {
+ functionCall: true,
+ reasoning: true,
+ search: true,
+ },
+ contextWindowTokens: 200_000,
+ description:
+ 'GLM-5.1 is Zhipu’s latest flagship model, aligned with Claude Opus 4.6 on overall and coding capabilities. It excels at long-horizon tasks, able to autonomously plan, execute, and iterate for up to 8 hours in a single task, making it an ideal foundation for Autonomous Agents and long-horizon Coding Agents.',
+ displayName: 'GLM-5.1',
+ enabled: true,
+ id: 'glm-5.1',
+ maxOutput: 131_072,
+ pricing: {
+ currency: 'CNY',
+ units: [
+ {
+ lookup: {
+ prices: {
+ '[0, 0.032]': 1.3,
+ '[0.032, infinity]': 2,
+ },
+ pricingParams: ['textInput'],
+ },
+ name: 'textInput_cacheRead',
+ strategy: 'lookup',
+ unit: 'millionTokens',
+ },
+ {
+ lookup: {
+ prices: {
+ '[0, 0.032]': 6,
+ '[0.032, infinity]': 8,
+ },
+ pricingParams: ['textInput'],
+ },
+ name: 'textInput',
+ strategy: 'lookup',
+ unit: 'millionTokens',
+ },
+ {
+ lookup: {
+ prices: {
+ '[0, 0.032]': 24,
+ '[0.032, infinity]': 28,
+ },
+ pricingParams: ['textInput'],
+ },
+ name: 'textOutput',
+ strategy: 'lookup',
+ unit: 'millionTokens',
+ },
+ ],
+ },
+ releasedAt: '2026-03-27',
+ settings: {
+ extendParams: ['enableReasoning'],
+ searchImpl: 'params',
+ },
+ type: 'chat',
+ },
{
abilities: {
functionCall: true,
diff --git a/packages/model-runtime/src/providers/zhipu/index.test.ts b/packages/model-runtime/src/providers/zhipu/index.test.ts
index 42a8510e5a1..439190c7f70 100644
--- a/packages/model-runtime/src/providers/zhipu/index.test.ts
+++ b/packages/model-runtime/src/providers/zhipu/index.test.ts
@@ -384,6 +384,29 @@ describe('LobeZhipuAI - custom features', () => {
});
});
+ describe('tool_stream for streaming tool calls', () => {
+ it.each([
+ ['glm-4.6', true, true],
+ ['glm-4.7', true, true],
+ ['glm-5', true, true],
+ ['glm-5.1', true, true],
+ ['glm-4.5', true, undefined],
+ ['glm-5-turbo', true, undefined],
+ ['glm-4', true, undefined],
+ ['glm-5.1', false, undefined],
+ ] as const)('model=%s stream=%s → tool_stream=%s', async (model, stream, expected) => {
+ await instance.chat({
+ messages: [{ content: 'Hello', role: 'user' }],
+ model,
+ stream,
+ temperature: 0.5,
+ });
+
+ const callArgs = (instance['client'].chat.completions.create as any).mock.calls[0][0];
+ expect(callArgs.tool_stream).toBe(expected);
+ });
+ });
+
describe('Preserve other payload properties', () => {
it('should preserve all other properties', async () => {
await instance.chat({
diff --git a/packages/model-runtime/src/providers/zhipu/index.ts b/packages/model-runtime/src/providers/zhipu/index.ts
index ad488514982..7b7b768f44b 100644
--- a/packages/model-runtime/src/providers/zhipu/index.ts
+++ b/packages/model-runtime/src/providers/zhipu/index.ts
@@ -81,7 +81,7 @@ export const params = {
model,
stream,
thinking: thinking ? { type: thinking.type } : undefined,
- tool_stream: stream && /^glm-(?:4\.(?:6|7)|5)$/.test(model) ? true : undefined,
+ tool_stream: stream && /^glm-(?:4\.(?:6|7)|5(?:\.1)?)$/.test(model) ? true : undefined,
tools: zhipuTools,
} as any;
},