fix(provider/zai): probe endpoint in runtime_provider for Coding Plan keys - #31282
Closed
bogerman1 wants to merge 1 commit into
Closed
fix(provider/zai): probe endpoint in runtime_provider for Coding Plan keys#31282bogerman1 wants to merge 1 commit into
bogerman1 wants to merge 1 commit into
Conversation
…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)
Contributor
Author
|
Labels: No permission to add labels directly — maintainer please tag. |
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Z.AI Coding Plan API keys only work on
/api/coding/paas/v4, not the standard/api/paas/v4. When a user configuresprovider: zaiin config.yaml (which defaultsbase_urlto/api/paas/v4), Coding Plan keys get HTTP 429 "Insufficient balance or no resource package" on every request.The existing
_resolve_zai_base_url()inauth.pycorrectly 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 inruntime_provider.pybypassed the probe entirely.Root Cause
In
_resolve_explicit_runtime()(runtime_provider.py:833-839), thezaiprovider falls into the genericelsebranch:No endpoint probe is performed. The
kimi-codingprovider already has a special branch here that calls its own resolver —zaineeds 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 forkimi-coding. 11 lines added, 0 lines changed.Verification
Tested on WSL2 with Coding Plan key:
paas/v4returns 429coding/paas/v4returns 200Related