更新时间:2026-08-27 | 核验来源:智谱开放平台官方文档 + GitHub 开源页 + 第三方实测
🔥 为什么 GLM-4.7-Flash 值得关注
- 永久免费:2026年1月20日发布即宣布 API 永久免费,无额度限制、无有效期
- 轻量化 MoE:总参数 30B,每次推理仅激活 3B,速度/成本双优
- 200K 超长上下文:适合长文档总结、代码库检索、Agent 多轮对话
- 本地可跑:苹果 M5 实测 43 token/s(Q4_量化),支持 FP16/Q4_0/Q4_K 等多精度
- 编程/Agent 专精:官方定位「本地编程与智能体助手」,函数调用/工具调用原生支持
📌 快速上手 3 步走
1. 注册账号 & 获取 API Key
⚠️ 注意:国内/国际账号 API Key 不互通,端点也不同
2. 选择正确端点
| 用户类型 |
Base URL |
适用场景 |
| 国内(CN) |
https://open.bigmodel.cn/api/paas/v4 |
大陆手机号注册、国内网络 |
| 国际(Global) |
https://api.z.ai/api/paas/v4 |
邮箱注册、海外网络 |
3. OpenAI 兼容调用示例
# cURL 示例(国内端点)
curl https://open.bigmodel.cn/api/paas/v4/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-4.7-flash",
"messages": [{"role": "user", "content": "Hello, write a Python function to sort a list."}],
"max_tokens": 1024,
"temperature": 0.7
}'
# Python + OpenAI SDK(推荐)
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://open.bigmodel.cn/api/paas/v4" # 国际用户改为 https://api.z.ai/api/paas/v4
)
response = client.chat.completions.create(
model="glm-4.7-flash",
messages=[{"role": "user", "content": "用 Python 写一个快速排序"}],
max_tokens=2048,
temperature=0.3
)
print(response.choices[0].message.content)
🛠️ 高级用法:Prompt Caching 降本
GLM-4.7-Flash 支持 Prompt Caching(缓存重复前缀),适合:
- 固定 System Prompt 的 Agent
- 长文档分块检索(RAG)
- 多轮对话历史复用
# 启用缓存(缓存前缀自动识别)
response = client.chat.completions.create(
model="glm-4.7-flash",
messages=[
{"role": "system", "content": "你是一个 Python 编程助手,擅长优化代码性能。" * 100}, # 长前缀会被缓存
{"role": "user", "content": "优化这段代码:..."}
],
extra_body={"prompt_cache": True} # 显式启用缓存
)
💡 缓存命中后,输入 Token 成本可降低 80-90%(官方实测数据)
📊 性能对比(官方 + 第三方实测)
| 模型 |
参数量 |
上下文 |
速度 (M5) |
免费政策 |
| GLM-4.7-Flash |
30B/3B MoE |
200K |
43 tok/s |
永久免费 |
| GLM-4.5-Flash |
15B |
128K |
28 tok/s |
永久免费 |
| DeepSeek-V4-Flash |
236B/21B MoE |
128K |
- |
峰谷定价(8月新规) |
| Qwen2.5-72B |
72B |
256K |
- |
免费额度 + 按量 |
⚠️ 注意事项
- 速率限制:免费用户默认 10 RPM / 1000 TPM,如需提升可申请企业认证
- 内容审核:国内端点强制内容安全过滤,国际端点较宽松
- 模型更新:GLM-4.7-Flash 会持续迭代,建议订阅官方 changelog
- 本地部署:如需私有化,可从魔搭社区/AtomGit 下载权重(MIT 许可)
🔗 官方资源
- 智谱开放平台(CN):https://open.bigmodel.cn
- 智谱开放平台(Global):https://api.z.ai
- GitHub 开源:https://github.com/THUDM/GLM-4.7-Flash
- 魔搭社区权重:https://modelscope.cn/models/ZhipuAI/glm-4.7-flash
下一步:需要统一接入多家免费 API?查看 统一调用网关教程 或 成本优化策略。
Last Updated: 2026-08-27 | Verified Sources: Zhipu Open Platform Official Docs + GitHub Repo + Third-party Tests
🔥 Why GLM-4.7-Flash Matters
- Free Forever: API announced free forever since Jan 20, 2026 launch — no quota limits, no expiry
- Lightweight MoE: 30B total params, only 3B activated per inference — optimal speed/cost
- 200K Context: Ideal for long doc summarization, codebase retrieval, multi-turn Agent chats
- Locally Runnable: 43 token/s on Apple M5 (Q4_ quantized), supports FP16/Q4_0/Q4_K
- Coding/Agent Specialist: Official positioning as "Local Programming & Agent Assistant", natively supports function/tool calling
📌 Quick Start in 3 Steps
1. Register & Get API Key
⚠️ Note: CN/Global API Keys are not interchangeable, endpoints differ too
2. Choose Correct Endpoint
| User Type |
Base URL |
Use Case |
| CN (Mainland) |
https://open.bigmodel.cn/api/paas/v4 |
Phone-registered accounts, mainland network |
| Global |
https://api.z.ai/api/paas/v4 |
Email-registered accounts, overseas network |
3. OpenAI-Compatible Example
# cURL Example (CN endpoint)
curl https://open.bigmodel.cn/api/paas/v4/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-4.7-flash",
"messages": [{"role": "user", "content": "Hello, write a Python function to sort a list."}],
"max_tokens": 1024,
"temperature": 0.7
}'
# Python + OpenAI SDK (Recommended)
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://open.bigmodel.cn/api/paas/v4" # Global users: https://api.z.ai/api/paas/v4
)
response = client.chat.completions.create(
model="glm-4.7-flash",
messages=[{"role": "user", "content": "Write a quicksort in Python"}],
max_tokens=2048,
temperature=0.3
)
print(response.choices[0].message.content)
🛠️ Advanced: Prompt Caching for Cost Reduction
GLM-4.7-Flash supports Prompt Caching (cache repeated prefixes), ideal for:
- Agents with fixed System Prompts
- Long doc chunked retrieval (RAG)
- Multi-turn conversation history reuse
# Enable caching (long prefixes auto-detected)
response = client.chat.completions.create(
model="glm-4.7-flash",
messages=[
{"role": "system", "content": "You are a Python coding assistant, expert in performance optimization." * 100}, # Long prefix gets cached
{"role": "user", "content": "Optimize this code: ..."}
],
extra_body={"prompt_cache": True} # Explicitly enable cache
)
💡 After cache hit, input token cost can drop 80-90% (official benchmark)
| Model |
Params |
Context |
Speed (M5) |
Free Policy |
| GLM-4.7-Flash |
30B/3B MoE |
200K |
43 tok/s |
Free Forever |
| GLM-4.5-Flash |
15B |
128K |
28 tok/s |
Free Forever |
| DeepSeek-V4-Flash |
236B/21B MoE |
128K |
- |
Peak/Valley Pricing (Aug 2026) |
| Qwen2.5-72B |
72B |
256K |
- |
Free Tier + Pay-as-you-go |
⚠️ Important Notes
- Rate Limits: Free users default 10 RPM / 1000 TPM; apply for enterprise cert for higher limits
- Content Moderation: CN endpoint enforces strict content filtering; Global endpoint is more lenient
- Model Updates: GLM-4.7-Flash iterates continuously — subscribe to official changelog
- Local Deployment: For private use, download weights from ModelScope/AtomGit (MIT License)
🔗 Official Resources
Next Step: Need unified access to multiple free APIs? Check Unified Gateway Tutorial or Cost Optimization Strategies.