Skip to content

fix(provider/zai): probe endpoint in runtime_provider for Coding Plan keys - #31282

Closed
bogerman1 wants to merge 1 commit into
NousResearch:mainfrom
bogerman1:fix/zai-probe-override-config-base-url
Closed

fix(provider/zai): probe endpoint in runtime_provider for Coding Plan keys#31282
bogerman1 wants to merge 1 commit into
NousResearch:mainfrom
bogerman1:fix/zai-probe-override-config-base-url

Conversation

@bogerman1

Copy link
Copy Markdown
Contributor

Problem

Z.AI Coding Plan API keys only work on /api/coding/paas/v4, not the standard /api/paas/v4. When a user configures provider: zai in config.yaml (which defaults base_url to /api/paas/v4), Coding Plan keys get HTTP 429 "Insufficient balance or no resource package" on every request.

The existing _resolve_zai_base_url() in auth.py correctly probes all 4 Z.AI endpoints and auto-detects the right one per key type, but it was only called from the credential_pool code path. The main _resolve_explicit_runtime() path in runtime_provider.py bypassed the probe entirely.

Root Cause

In _resolve_explicit_runtime() (runtime_provider.py:833-839), the zai provider falls into the generic else branch:

else:
    base_url = env_url or pconfig.inference_base_url  # always paas/v4

No endpoint probe is performed. The kimi-coding provider already has a special branch here that calls its own resolver — zai needs the same treatment.

Fix

Add a zai-specific branch that calls _resolve_zai_base_url() to probe and detect the correct endpoint, following the exact same pattern already used for kimi-coding. 11 lines added, 0 lines changed.

Verification

# Standard key → probe detects paas/v4 ✅
# Coding Plan key → probe detects coding/paas/v4 ✅ (was 429 before)

Tested on WSL2 with Coding Plan key:

  • paas/v4 returns 429
  • coding/paas/v4 returns 200
  • After fix, gateway auto-detects coding endpoint

Related

…an keys

When a Z.AI Coding Plan API key is used, the key only works on
/api/coding/paas/v4, not the standard /api/paas/v4 endpoint.

The existing _resolve_zai_base_url() in auth.py correctly probes all
Z.AI endpoints and detects the right one, but it was only called from
the credential_pool code path. The main runtime provider path in
_resolve_explicit_runtime() skipped the probe entirely, using
pconfig.inference_base_url (which defaults to /api/paas/v4 from
config.yaml) regardless of the key type.

This caused HTTP 429 'Insufficient balance or no resource package' on
every request for Coding Plan users, even though their key was valid.

Fix: add a zai-specific branch in _resolve_explicit_runtime() that
calls _resolve_zai_base_url() to probe and detect the correct endpoint,
following the same pattern already used for kimi-coding.

Related: NousResearch#24915 (broader Z.AI provider overhaul, not yet merged)
@bogerman1 bogerman1 changed the title fix(zai): probe endpoint in runtime_provider for Coding Plan keys fix(provider/zai): probe endpoint in runtime_provider for Coding Plan keys May 24, 2026
@bogerman1

Copy link
Copy Markdown
Contributor Author

Labels: provider/zai area/auth comp/agent P2 type/bug

No permission to add labels directly — maintainer please tag.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists provider/zai ZAI provider comp/cli CLI entry point, hermes_cli/, setup wizard labels May 24, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for identifying the Z.AI Coding Plan endpoint distinction. This is an automated hermes-sweeper review; the reported config-driven behavior is already implemented on current main.

  • hermes_cli/runtime_provider.py:2009-2032 resolves normal API-key providers through resolve_api_key_provider_credentials() before selecting the runtime URL.
  • hermes_cli/auth.py:6460-6463 routes zai through _resolve_zai_base_url().
  • hermes_cli/auth.py:689-730 uses the cached detected endpoint or probes the Z.AI endpoint set and returns the working URL.
  • The PR's target, _resolve_explicit_runtime(), is only reached for explicit runtime key/URL overrides (hermes_cli/runtime_provider.py:1368-1371), not the config.yaml flow described in the report.

@teknium1 teknium1 closed this Jul 13, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists provider/zai ZAI provider sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants