用途:在需要调用智谱文本生成模型时,提供模型选型建议与 API 调用方式,适用于文本生成、对话、Agentic Coding、长链自主代理、办公自动化、角色扮演/剧本生成、专业翻译、结构化数据提取、客服质检等场景。
模型与选型:GLM-5(glm-5,744B/40B active,128K)定位旗舰与 Agentic Engineering;GLM-4.7(glm-4.7,128K)为性价比旗舰;GLM-4.7-FlashX(glm-4.7-flashx,128K)偏高速;GLM-4.6(glm-4.6,355B/32B active,128K)偏稳定;GLM-4.5 系列含 5 个变体,覆盖不同性能与成本需求;GLM-4.7-Flash(glm-4.7-flash,30B,200K)为免费且上下文较长的选择。
共享能力:所有文本模型支持 thinking mode(thinking.type: enabled/disabled)、streaming、Function Calling、上下文缓存、结构化 JSON Schema 输出、MCP 支持。
使用方式:API Key 从 ~/.glm/.env 加载,变量名 ZHIPU_API_KEY,获取地址 https://open.bigmodel.cn/usercenter/apikeys。接口为 POST https://open.bigmodel.cn/api/paas/v4/chat/completions,认证使用 Bearer token,Content-Type: application/json;请求体包含 model、messages、stream、temperature、max_tokens。Thinking mode 以 "thinking": {"type": "enabled"} 配置。SDK 示例:from zai import ZhipuAI;client = ZhipuAI(api_key="your-key");response = client.chat.completions.create(model="glm-5", messages=[{"role": "user", "content": "你好"}])。
限制:资料未提供各模型的收费与价格、速率限制、配额及具体参数默认值,相关事实暂未提供;文档参考 https://docs.bigmodel.cn/ 与 https://open.bigmodel.cn/usercenter/apikeys。