最后更新

Codex GLM:在 Codex 中使用 GLM-5.2

本指南教你如何用 Codex Router 把 GLM 模型——GLM-5.2 与 GLM-5-Turbo——加进 Codex 模型选择器。GLM 有两条单独计费的路径:Ollama Cloud 供应商与 Z.ai GLM Coding Plan 供应商。

GLMGLMOllama CloudCoding Plan

可以添加什么

选择器标签模型 ID认证方式
GLM-5.2 (Ollama Cloud)ollama-cloud/glm-5.2Ollama Cloud API Key
GLM-5.2 (Coding Plan)zai-coding/glm-5.2Z.ai GLM Coding Plan API Key
GLM-5-Turbo (Coding Plan)zai-coding/glm-5-turboZ.ai GLM Coding Plan API Key

GLM-5.2 还被阿里云百炼 plan 转售为 qwen-plan/glm-5.2——该条目因由阿里云 plan 计费而与两条直连路径共存。本页讲两条直连路径。

选择路径

  • Ollama Cloud 通过 ollama.com 账户计费。你拿到账户 API Key,路由器从 Ollama 发布的模型元数据读取上下文窗口。已用 Ollama 或想把 GLM 与 Kimi K2.7 Code、MiniMax M3、DeepSeek V4 Pro 等 Ollama Cloud 模型放一起的话选这个。
  • Z.ai GLM Coding Plan 使用该计划专用编码端点及其订阅 API Key。订阅了 GLM Coding Plan、想用计划配额与 zai-coding 供应商思考行为的话选这个。

启用 Ollama Cloud

./bin/model-router codex provider-key ollama-cloud set
./bin/model-router codex providers enable ollama-cloud

密钥提示是隐藏的,值保存在受保护的按用户文件中。Windows 上用 ./codex-router.ps1 codex provider-key ollama-cloud set

启用 Z.ai GLM Coding Plan

./bin/model-router codex provider-key zai-coding set
./bin/model-router codex providers enable zai-coding

Z.ai coding 密钥与普通 Z.ai 平台密钥不可互换。 只有 GLM Coding Plan 订阅密钥能在编码端点工作,且 Z.ai 把该端点保留给交互式编码工具。普通 Z.ai 平台密钥在此路由上会认证失败。

验证集成

./bin/model-router codex doctor
./bin/model-router codex providers

你启用的供应商必须报告 SHOWready。然后完全退出 Codex、重新打开、新建任务,在选择器中找 GLM-5.2。实时(消耗配额)检查:

./bin/test-model 'zai-coding/glm-5.2' --live --yes

GLM 请求的行为

zai-coding 路由使用 GLM Coding Plan 专用编码端点、启用思考、把 Codex 最高推理档位映射到 Z.ai 的 max effort,并移除与思考模式冲突的采样覆盖。GLM-5.2 暴露两个文档化 effort 档位;转发器显式发送它们,省略参数时上游默认 max,与 Z.ai 建议一致。GLM-5-Turbo 不宣传它不支持的 effort 控制。

常见坑

  • 密钥与配额按供应商隔离。 Ollama Cloud 密钥计入 Ollama,Z.ai Coding Plan 密钥计入 Z.ai,阿里云 plan 密钥计入阿里云;互不认证。
  • 选择器缺失通常意味着凭据缺失。 确认供应商报告 ready 后重启 Codex。见模型缺失
  • 供应商策略风险。 Z.ai 与 ollama.com 可能限制或封禁代理流量。通过 Codex Router 使用 GLM 风险自负。
  • Windows 用户: 密钥命令走 ./codex-router.ps1 codex provider-key ...,其余流程相同。

官方链接

相关:模型总览Codex 中的 DeepSeekCodex 中的 Kimi安装