Implement the following plan: Plan: Add Z.AI Coding Plan Provider (zai-code) Context…
- User
Implement the following plan:
Plan: Add Z.AI Coding Plan Provider (
zai-code)Context
GitHub issue #414: Z.AI users on the Coding plan get "insufficient balance" errors because Moltis only targets the general API endpoint (
https://api.z.ai/api/paas/v4). Z.AI has a separate Coding plan endpoint (https://api.z.ai/api/coding/paas/v4) with different billing. OpenClaw handles this by detecting the plan type during setup. The fix is to add a second, non-breakingzai-codeprovider alongside the existingzaiprovider.Changes
1.
crates/providers/src/lib.rsAdd
OpenAiCompatDefforzai-code(after the existingzaientry, ~line 1014):rustOpenAiCompatDef { config_name: "zai-code", env_key: "Z_CODE_API_KEY", env_base_url_key: "Z_CODE_BASE_URL", default_base_url: "https://api.z.ai/api/coding/paas/v4", models: ZAI_MODELS, supports_model_discovery: true, requires_api_key: true, local_only: false, },Add test (after
zai_registers_with_api_key, ~line 3092):rust#[test] fn zai_code_registers_with_api_key() { // ... same pattern as zai test but with "zai-code" / "sk-test-zai-code" }Update
context_window_for_model— existing GLM match already covers allglm-*models, no change needed.Update
supports_vision— existing GLM match already covers allglm-*models, no change needed.2.
crates/provider-setup/src/lib.rsAdd
KnownProviderforzai-code(after thezaientry, ~line 855):rust Assistant
I'll read the relevant files in parallel to understand the current code before making changes.
Assistant
Now let me read the specific code sections around those lines.
Assistant
Now I also need to check the provider-setup test for the
offeredlist and the docs for any Z.AI-specific section.Assistant
I have all the context I need. Let me make all the edits now.
Assistant
All edits are done. Let me run the tests and format check.
Assistant
Formatting is clean. Let me check on the tests.
Assistant
Still compiling. Let me wait for the background task to finish.
Assistant
Tests are still running. Let me wait a bit and check again.
Assistant
Still compiling the workspace. Let me wait for completion.
Assistant
The filter
zaididn't match the test names. The tests are named with underscores. Let me run with the correct filter.Assistant
All tests pass. Let me also run the remaining provider-setup tests that reference zai.
Assistant
All tests pass across all three crates. Here's a summary of all changes:
Files modified (6):
-
crates/providers/src/lib.rs— Addedzai-codeOpenAiCompatDefwithZ_CODE_API_KEYandhttps://api.z.ai/api/coding/paas/v4endpoint, reusingZAI_MODELS. Addedzai_code_registers_with_api_keytest. -
crates/provider-setup/src/lib.rs— Addedzai-codeKnownProviderentry. Updated 4 test arrays to includezai-code. -
crates/config/src/provider_env.rs— Added normalization aliases:"zai-code" | "zai-coding" | "zhipu-code" => "zai-code". -
crates/config/src/template.rs— Addedzai-codeto the commented provider list. -
docs/src/providers.md— Addedzai-coderow to the providers table.
The existing
zaiprovider is untouched. All tests pass and formatting is clean.-
Assistant
The background
cargo test zaialso completed successfully (exit code 0). As noted earlier, thezaifilter matched zero test names (they use underscores likezai_registers_with_api_key), but the targeted runs I did afterward confirmed all tests pass. Implementation is complete.- User
commit and push, create a PR
Assistant
Dolt remote is down, proceeding with push and PR.
Assistant
PR created: https://github.com/moltis-org/moltis/pull/517
- User
Fix comments from https://github.com/moltis-org/moltis/pull/517 and resolve conversations
Assistant
Two comments from greptile:
- docs/providers.md: Use capability list format instead of description in the Features column
- provider_env.rs: Add test coverage for the new normalization aliases
Let me fix both and find where to add the test.
Assistant
Tests pass, formatting clean. Now commit, push, and resolve the conversations.
Assistant
Now resolve both conversations.
Assistant
Done. Both review comments are fixed and resolved:
- docs/providers.md — Changed to capability list format:
Streaming, tools, model discovery (Coding plan billing endpoint) - provider_env.rs — Added
normalize_zai_code_aliasestest covering all three aliases
- docs/providers.md — Changed to capability list format: