Skip to main content

Zhipu AI

Zhipu AI's GLM (General Language Model) series — powerful Chinese-English bilingual models with function calling support.

Install

pip install synapsekit[openai]

Uses the openai SDK with Zhipu's API endpoint.

Usage

from synapsekit.llm.zhipu import ZhipuLLM
from synapsekit import LLMConfig

config = LLMConfig(
model="glm-4",
api_key="your-zhipu-api-key",
provider="zhipu",
)

llm = ZhipuLLM(config)

# Streaming
async for token in llm.stream("请解释量子计算的基本原理"):
print(token, end="")

# Generate
response = await llm.generate("What are the key features of GLM-4?")

Available models

ModelContextNotes
glm-4128KFlagship, strongest quality
glm-4-air128KFaster, lower cost
glm-4-flash128KFastest, free tier available
glm-3-turbo128KPrevious generation, very low cost

Function calling

from synapsekit import FunctionCallingAgent, tool

@tool
def search_knowledge(query: str) -> str:
"""Search a knowledge base for relevant information."""
return f"Results for '{query}': relevant information found."

llm = ZhipuLLM(LLMConfig(model="glm-4", api_key="..."))
agent = FunctionCallingAgent(llm=llm, tools=[search_knowledge])
answer = await agent.run("搜索关于深度学习的信息")

Auto-detection

The RAG facade auto-detects Zhipu for glm-* model prefixes:

from synapsekit import RAG

rag = RAG(model="glm-4", api_key="...")
rag.add("Your document text here")
answer = rag.ask_sync("Summarize this.")
tip

GLM-4 models are particularly strong at Chinese language tasks. glm-4-flash is free within rate limits — ideal for development and testing.