概述
GLM-5.2 是 GLM-5 系列的旗舰基座模型,主线能力覆盖文本生成、深度推理与代码工程。围绕"长任务持续可用"的目标,我们重新设计了上下文压缩路径与目标一致性维护机制,让模型在跨多日的研发协作中能稳定记住关键约束;同时在长链路工程任务中持续对齐用户意图,避免上下文漂移。配合多档思考强度、Function Calling、MCP 工具与结构化输出能力,它可以直接驱动项目级软件开发与复杂自动化流水线。
百万上下文
1M token 上下文窗口,支持项目级代码库与超长文档一次性载入。
长程智能体
面向多步、长周期 agentic 工作流优化,任务中持续维护工程上下文。
多档思考模式
提供 high / xhigh 等推理强度档位,覆盖从快速响应到深度推理场景。
开源可部署
模型权重开源,支持私有化部署与企业级二次开发。
功能
工具调用✓
结构化输出✓
上下文缓存✓
批量任务✓
联网搜索✓
流式输出✓
深度思考✓
MCP✓
前缀补全✕
微调✕
定价
输入$1.4/M tokens
输入(缓存命中)$0.26/M tokens
输出$4.4/M tokens
速率限制与上下文
上下文窗口1M
最大输出128K
RPM(请求 / 分钟)200
TPM(token / 分钟)3M
内置工具
code_interpreter
Responses API
web_extractor
Responses API
web_search
Responses API
API 参考
POST
https://api.tokenfab.com/v1/chat/completions请求示例
curl https://api.tokenfab.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKENFAB_API_KEY" \
-d '{
"model": "glm-5.2",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Implement quicksort in Python and include a time complexity analysis."}
]
}'import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("TOKENFAB_API_KEY"),
base_url="https://api.tokenfab.com/v1"
)
response = client.chat.completions.create(
model="glm-5.2",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Implement quicksort in Python and include a time complexity analysis."}
]
)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.TOKENFAB_API_KEY,
baseURL: "https://api.tokenfab.com/v1"
});
const response = await client.chat.completions.create({
model: "glm-5.2",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Implement quicksort in Python and include a time complexity analysis." }
]
});
console.log(response.choices[0].message.content);响应示例
{
"id": "chatcmpl-9d2k7f1",
"object": "chat.completion",
"created": 1784950000,
"model": "glm-5.2",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Quicksort uses divide and conquer: pick a pivot, partition the array into elements smaller and larger than the pivot, sort each part recursively, then combine. Best case O(n log n), worst case O(n²)."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 128,
"total_tokens": 143
}
}请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | ✓ | 模型 ID,如 glm-5.2 或 GLM-5.1 |
messages | array | ✓ | 对话消息列表,含 role 和 content |
temperature | float | — | 采样温度,0–2,默认 0.7 |
top_p | float | — | 核采样,0–1,默认 0.9 |
max_tokens | int | — | 最大输出 Token 数 |
stream | bool | — | 是否流式输出,默认 false |
tools | array | — | 工具定义列表,用于 Function Calling |
tool_choice | string | — | 工具调用策略,auto / none / 指定函数 |