Skip to content

[codex] fix Zhipu coding plan presets#3524

Merged
farion1231 merged 2 commits into
mainfrom
codex/fix-zhipu-coding-plan-presets
Jun 3, 2026
Merged

[codex] fix Zhipu coding plan presets#3524
farion1231 merged 2 commits into
mainfrom
codex/fix-zhipu-coding-plan-presets

Conversation

@makoMakoGo

@makoMakoGo makoMakoGo commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

摘要

修正智谱 / Z.AI GLM 预设在 OpenAI-compatible 应用里的默认端点,让这组预设实际走到 Coding Plan 对应的调用路径。

Closes #3471 (#3471)

背景

大多数用户选择这组预设时,预期是使用已订阅的 Coding Plan 额度,而不是普通 GLM API 计费路径。如果新增 coding plan 专用预设的话,考虑到当前预设数量已经很多了,感觉不好,并且 Claude Code 那块的语义已经差不多默认当前预设是 GLM Coding Plan 了,如 #3471

并且智谱的端点规则比较特殊:

  • 正常 API 计费和 Coding Plan 的 Anthropic-compatible / Claude Code 路径均使用 https://open.bigmodel.cn/api/anthropic
  • 普通 OpenAI-compatible GLM API 使用 /api/paas/v4/v1 这类普通端点
  • GLM Coding Plan 在 OpenAI-compatible 工具中需要使用专属 Coding API:/api/coding/paas/v4

Anthropic-compatible 侧和 OpenAI-compatible 侧的端点规则并不对称。之前 Codex / OpenCode / OpenClaw / Hermes 的相关预设使用了普通 OpenAI-compatible 端点,用户选择预设后仍可能没有走到 Coding Plan 对应的调用路径(如 #3471)。

改动

  • 将 Codex / OpenCode / OpenClaw / Hermes 的中国站 Coding Plan 端点改为:
    • https://open.bigmodel.cn/api/coding/paas/v4
  • 将 Codex / OpenCode / OpenClaw / Hermes 的海外站 Coding Plan 端点改为:
    • https://api.z.ai/api/coding/paas/v4
  • 同步更新 OpenCode / OpenClaw 表单中的 placeholder 和 defaultValue。
  • 同步更新 Codex preset 单测期望。

本次不修改预设展示名、provider key、模型 ID、Codex TOML provider name、OpenCode settingsConfig.name、Hermes provider name 等标识字段;只修正默认端点,因此不会影响已有用户配置,也不需要数据迁移。

Validation

  • pnpm exec prettier --check src/config/codexProviderPresets.ts src/config/opencodeProviderPresets.ts src/config/openclawProviderPresets.ts src/config/hermesProviderPresets.ts tests/config/codexChatProviderPresets.test.ts
  • pnpm exec tsc --noEmit --ignoreDeprecations 5.0
  • pnpm exec vitest run tests/config/codexChatProviderPresets.test.ts tests/config/opencodeProviderPresets.test.ts

@makoMakoGo
makoMakoGo force-pushed the codex/fix-zhipu-coding-plan-presets branch from b3237ae to b2b8f60 Compare June 1, 2026 15:13
@makoMakoGo
makoMakoGo marked this pull request as ready for review June 1, 2026 15:16
@makoMakoGo
makoMakoGo marked this pull request as draft June 1, 2026 15:24
@makoMakoGo

makoMakoGo commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

原本想要 把 preset display name 也修正为 Coding Plan 的 ....... 我在思考这个 pr 到底值不值得。算了我觉得还是值得的,虽然小(智谱 x 某华学校交流群 之前也有例子被这个预设困惑过的....),毕竟用 GLM 预设的基本都是 Coding Plan 用户。 只改 url,不扩大到 preset display name 也修正了。

@makoMakoGo
makoMakoGo force-pushed the codex/fix-zhipu-coding-plan-presets branch from 6b312ef to e50ba8b Compare June 1, 2026 15:30
@makoMakoGo
makoMakoGo marked this pull request as ready for review June 1, 2026 15:33
@makoMakoGo

Copy link
Copy Markdown
Collaborator Author

顺带提一个已知问题,当前 获取 模型逻辑 在不已 v1 结尾时 补 v1/models,对于智谱这种 v4 这种结尾的 只补 /models 就行,多了反而请求错误。所以 pr 里 没管,这块逻辑动起来比较麻烦。

#3471 (comment)

@farion1231

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The model-list probe assumed any base URL not ending in /v1 needs /v1/models appended. For providers whose base URL already ends in a version segment like /v4 (Zhipu/Z.AI GLM Coding Plan at .../api/coding/paas/v4), this produced .../v4/v1/models which 404s, so the "Fetch models" button always failed.

Detect a trailing /v{N} version segment and probe {base}/models first, keeping /v1/models as a fallback candidate for non-/v1 versions. Fixes Codex/OpenCode/OpenClaw/Hermes GLM presets and any other vN-style endpoint, with no behavior change for /v1 or non-versioned URLs.

@farion1231 farion1231 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢您的贡献!

@farion1231
farion1231 merged commit e891f5c into main Jun 3, 2026
3 checks passed
gfunc pushed a commit to gfunc/cc-switch that referenced this pull request Jun 19, 2026
* fix(presets): update Zhipu coding plan endpoints

* fix(model-fetch): probe /models on versioned /vN base URLs

The model-list probe assumed any base URL not ending in /v1 needs /v1/models appended. For providers whose base URL already ends in a version segment like /v4 (Zhipu/Z.AI GLM Coding Plan at .../api/coding/paas/v4), this produced .../v4/v1/models which 404s, so the "Fetch models" button always failed.

Detect a trailing /v{N} version segment and probe {base}/models first, keeping /v1/models as a fallback candidate for non-/v1 versions. Fixes Codex/OpenCode/OpenClaw/Hermes GLM presets and any other vN-style endpoint, with no behavior change for /v1 or non-versioned URLs.

---------

Co-authored-by: Jason <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 建议提示用户在使用智谱 Coding 模型时修改 Base URI

2 participants