Skip to content

fix(zai): resolve model list for China API users (endpoint-aware) - #46724

Open
Icather wants to merge 3 commits into
NousResearch:mainfrom
Icather:fix/zai-model-list
Open

fix(zai): resolve model list for China API users (endpoint-aware)#46724
Icather wants to merge 3 commits into
NousResearch:mainfrom
Icather:fix/zai-model-list

Conversation

@Icather

@Icather Icather commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes Z.AI model listing for two bugs:

Bug 1 -- provider_model_ids resolves the correct endpoint URL (e.g. China's open.bigmodel.cn) via resolve_api_key_provider_credentials, but fetch_models still hits the hardcoded international URL (api.z.ai). China API keys are rejected, falling back to fallback_models (only 2 models).

Bug 2 -- Z.AI's /v1/models omits universally-free Flash models (glm-4v-flash, glm-4.6v-flash, glm-4.1v-thinking-flash, glm-4.5-flash, glm-4-flash-250414) even though they accept real API calls. The fix appends them via an override on the Z.AI ProviderProfile.fetch_models.

Related Issue

Type of Change

  • 🐛 Bug fix

Changes Made

  • plugins/model-providers/zai/__init__.py -- Added ZAI_FREE_MODELS constant (5 universally-free models). Overrode fetch_models to append these after the live API response with dedup.
  • hermes_cli/models.py -- Added base_url swap in the generic live-fetch path so fetch_models hits the resolved endpoint instead of the hardcoded profile default.

How to Test

  1. Configure a Z.AI API key via the China platform (open.bigmodel.cn)
  2. Open Dashboard → Models page → select Z.AI provider
  3. Verify 12 models appear (7 live + 5 free Flash)
  4. Select a free vision model (e.g. glm-4v-flash) as auxiliary vision model -- confirm it works

Checklist

Code

  • Commit messages follow Conventional Commits
  • Searched for existing PRs (closed fix(models): merge Z.AI curated models with live API results #46623 is superseded by this)
  • PR contains only related changes
  • Tested on: Windows 11
  • Run pytest tests/ -q -- N/A (no new tests; fix is integration-level)
  • Added tests -- N/A (requires live Z.AI API key)

Documentation & Housekeeping

  • Updated relevant documentation -- N/A
  • Updated cli-config.yaml.example -- N/A
  • Updated CONTRIBUTING.md or AGENTS.md -- N/A
  • Considered cross-platform impact -- Yes (fix applies to both international and China endpoints)
  • Updated tool descriptions/schemas -- N/A

Two independent fixes:

1. URL routing: provider_model_ids resolved the correct China base URL
   (open.bigmodel.cn) via resolve_api_key_provider_credentials but
   fetch_models still used the hardcoded international URL (api.z.ai).
   China API keys were rejected by the international endpoint, falling
   back to fallback_models (glm-5 + glm-4-9b). Fix: temporarily swap
   the ProviderProfile base_url to the resolved URL before calling
   fetch_models.

2. Free model visibility: Z.AI /v1/models omits universally-free Flash
   models (glm-4v-flash, glm-4.6v-flash, glm-4.1v-thinking-flash,
   glm-4.5-flash, glm-4-flash-250414) even though they accept real API
   calls. Fix: override fetch_models on the Z.AI ProviderProfile to
   append ZAI_FREE_MODELS after the live API response with dedup.

All Z.AI-specific logic lives in plugins/model-providers/zai/__init__.py.
models.py only gains the base_url swap — zero zai-specific branches.
Copilot AI review requested due to automatic review settings June 15, 2026 15:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for Z.AI “universally-free” models that are not returned by the provider’s /v1/models endpoint, and updates CLI model fetching to respect a resolved per-region base URL.

Changes:

  • Add a Z.AI free-model allowlist and a wrapper around fetch_models() to append them.
  • Remove glm-5.2 from Z.AI fallback models.
  • In hermes_cli, temporarily apply the resolved base_url while fetching live models.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
plugins/model-providers/zai/init.py Adds free-model list and wraps fetch_models to append those models.
hermes_cli/models.py Ensures fetch_models uses the resolved (possibly regional) base_url.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/model-providers/zai/__init__.py Outdated
Comment thread plugins/model-providers/zai/__init__.py
Comment thread hermes_cli/models.py Outdated
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard comp/plugins Plugin system and bundled plugins provider/zai ZAI provider area/config Config system, migrations, profiles P2 Medium — degraded but workaround exists labels Jun 15, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the targeted Z.AI investigation. The resolved-endpoint part has since landed on current main in 1b962f001: hermes_cli/models.py:2485 passes the credential-resolved base_url, and providers/base.py:189-194 uses it for /models.

Problems

  • The proposed wrapper at plugins/model-providers/zai/__init__.py:14 does not accept base_url, but current main now calls fetch_models(api_key=..., base_url=...) at hermes_cli/models.py:2485; salvaging this unchanged would raise TypeError.
  • Its call at plugins/model-providers/zai/__init__.py:16 also omits base_url, which would discard the resolved China endpoint.
  • Current main already has ZaiProfile (plugins/model-providers/zai/__init__.py:85), so an override there is preferable to replacing a method on one instance.

Suggested changes

  • Rework the remaining free-model addition as a ZaiProfile.fetch_models override that accepts and forwards base_url, normalizes an empty live result, and deduplicates the appended IDs.
  • Add an offline regression test for the resolved URL and empty-catalog path.

Automated hermes-sweeper review.

"glm-4.6v-flash",
"glm-4.1v-thinking-flash",
"glm-4.5-flash",
"glm-4-flash-250414",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Current main invokes API-key profiles as fetch_models(api_key=..., base_url=...) in hermes_cli/models.py:2485. This keyword-only wrapper does not accept base_url, so salvaging it unchanged raises TypeError; add and forward that parameter.

"glm-4.5-flash",
"glm-4-flash-250414",
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Forward the resolved base_url here. Current ProviderProfile.fetch_models uses that override to select the endpoint (providers/base.py:189-194); omitting it would fall back to the profile's international default and undo the China routing fix.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/cli CLI entry point, hermes_cli/, setup wizard comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists provider/zai ZAI provider sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants