Skip to content

AI-native design editor. Open-source Figma alternative.

Add Z.ai support to AI providers and chat functionality (#90)

Dipankar Shawc4db9ec165d4
diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.ts
index 06e402f98..b67b92405 100644
--- a/packages/core/src/constants.ts
+++ b/packages/core/src/constants.ts
@@ -93,6 +93,7 @@ export type AIProviderID =
| 'openai'
| 'google'
| 'openai-compatible'
+ | 'zai'
| 'anthropic-compatible'
export interface ModelOption {
@@ -171,6 +172,27 @@ export const AI_PROVIDERS: AIProviderDef[] = [
{ id: 'gemini-3-flash-preview', name: 'Gemini 3 Flash', tag: 'Fast' }
]
},
+ {
+ id: 'zai',
+ name: 'Z.ai',
+ keyPlaceholder: 'API key',
+ keyURL: 'https://docs.z.ai/api-reference/introduction',
+ defaultModel: 'glm-5',
+ models: [
+ { id: 'glm-5', name: 'GLM-5' },
+ { id: 'glm-5-code', name: 'GLM-5-Code' },
+ { id: 'glm-4.7', name: 'GLM-4.7' },
+ { id: 'glm-4.7-flashx', name: 'GLM-4.7-FlashX' },
+ { id: 'glm-4.6', name: 'GLM-4.6' },
+ { id: 'glm-4.5', name: 'GLM-4.5' },
+ { id: 'glm-4.5-x', name: 'GLM-4.5-X' },
+ { id: 'glm-4.5-air', name: 'GLM-4.5-Air' },
+ { id: 'glm-4.5-airx', name: 'GLM-4.5-AirX' },
+ { id: 'glm-4-32b-0414-128k', name: 'GLM-4-32B-0414-128K' },
+ { id: 'glm-4.7-flash', name: 'GLM-4.7-Flash', tag: 'Free' },
+ { id: 'glm-4.5-flash', name: 'GLM-4.5-Flash', tag: 'Free' }
+ ]
+ },
{
id: 'openai-compatible',
name: 'OpenAI-compatible',
diff --git a/src/composables/use-chat.ts b/src/composables/use-chat.ts
index c00623e60..864937289 100644
--- a/src/composables/use-chat.ts
+++ b/src/composables/use-chat.ts
@@ -212,6 +212,13 @@ function createModel(): LanguageModel {
const google = createGoogleGenerativeAI({ apiKey: key })
return google(effectiveModelID)
}
+ case 'zai': {
+ const zai = createOpenAI({
+ apiKey: key,
+ baseURL: 'https://api.z.ai/api/paas/v4'
+ })
+ return zai.chat(effectiveModelID)
+ }
case 'openai-compatible': {
const custom = createOpenAI({
apiKey: key,