feat(zai): add Z.AI GLM model integration - #441
Conversation
Add a Z.AI GLM provider built on RegistryBackedProviderMixin and a JSON-driven model registry, following the project's modern provider pattern, and wire ZAI_API_KEY through the rest of the stack. * Add ZAIModelProvider hitting the standard /api/paas/v4 endpoint * Define GLM-4.6 in conf/zai_models.json (200K ctx, 128K output, text-only, intelligence_score 12) with field_descriptions and verification_sources * Wire the provider through providers/__init__, registry, server, listmodels, version, base_tool, model_restrictions, pyproject.toml * Pass ZAI_API_KEY through docker-compose, docker deploy/healthcheck scripts, and run_integration_tests entrypoints Refs: - https://docs.z.ai/guides/llm/glm-4.6 - https://docs.z.ai/api-reference/llm/chat-completion Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add unit + integration smoke tests for the Z.AI provider, extend shared test fixtures and listmodels/server/custom-provider tests to cover the new provider, and extend the Docker test suite so ZAI_API_KEY reaches parity with the other API keys. * tests/test_zai_provider.py: provider unit tests (init, capabilities, alias resolution, friendly name, MODEL_CAPABILITIES, restrictions, generate_content) matching XAI test coverage; integration smoke tests for auth failure and basic completion * tests/conftest.py, tests/test_custom_provider.py, tests/test_listmodels.py, tests/test_server.py: register and assert the Z.AI provider in shared fixtures and surfaces * tests/test_docker_*.py: assert ZAI_API_KEY parity across Docker config, healthcheck, implementation, MCP validation, and security Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Document the new Z.AI provider across user-facing docs and config examples, with the GLM-4.6 200K context window noted where relevant. * .env.example: add ZAI_API_KEY entry and note GLM-4.6's 200K context * README.md, docs/getting-started.md, docs/advanced-usage.md, docs/custom_models.md: add Z.AI to provider lists and user guides * docs/configuration.md: add Z.AI to API keys section, model table, config files list, allowed-models examples, and the manifest override path * docker/README.md, docs/docker-deployment.md: document ZAI_API_KEY for Docker deployments Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces support for the Z.AI (GLM) model provider. It includes the implementation of the ZAIModelProvider and ZAIModelRegistry, updates to the environment configuration, Docker setup, and comprehensive documentation. Additionally, it adds unit and integration tests to ensure the new provider functions correctly and integrates seamlessly with existing tools like listmodels and version. I have no feedback to provide.
The CI test failure on test_alias_allowlist_resolution happened because ``model_restrictions.is_allowed`` only resolves an allowed alias to its canonical target by looking the provider up via ``ModelProviderRegistry``. The test called ``reset_for_testing()`` and then never re-registered the ZAI provider, so the lookup returned None and ``glm-4.6`` validation fell through to ``return False``. * tests/test_zai_provider.py: re-register ZAI after reset_for_testing so is_allowed can resolve "glm" -> "glm-4.6" * tests/conftest.py: add ZAI_API_KEY to the dummy-key list so ``ModelProviderRegistry.get_provider(ZAI)`` returns an instance during tests (matches existing XAI_API_KEY behaviour) * requirements-dev.txt: pin ``black<26.0.0`` — black 26.x changed triple-quoted-string formatting for several upstream files that this PR doesn't touch (``simulator_tests/test_*``, ``test_directory_expansion_tracking``, ``test_prompt_regression``); pinning restores stable formatting for all contributors without dragging unrelated reformatting into this PR Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 23d9257a22
ℹ️ 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".
* add explicit JSON-backed range constraints * set GLM temperature max to Z.AI API limit * cover outbound temperature clamping
* clear Z.AI env in restricted-provider listing test * avoid CI leaking GLM aliases into expected allowlist
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf3debf7ca
ℹ️ 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".
* treat test placeholder Z.AI keys as absent * cover placeholder detection and dummy-key skip behavior
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7a873005b
ℹ️ 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".
* map PAL thinking levels to Z.AI thinking payload * pass extra_body through OpenAI-compatible requests * cover thinking payload forwarding
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4c8c3d572
ℹ️ 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".
* centralize Z.AI placeholder credential detection * reject both underscore and hyphenated docs placeholders * cover provider-registration placeholder checks
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 559db217eb
ℹ️ 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".
* include documented Z.AI placeholder spellings in smoke-test guard * verify both placeholders skip integration completion
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03a3836846
ℹ️ 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".
* add Z.AI to run-server env replacement checks * cover first-run .env population from exported ZAI_API_KEY
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22c3fc7e97
ℹ️ 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".
* include Z.AI in Windows env templates and API-key checks * propagate ZAI_API_KEY into generated client env maps * cover PowerShell Z.AI setup wiring
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 496329e77a
ℹ️ 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".
* include ZAI_ALLOWED_MODELS in PowerShell Qwen env fallback * cover Z.AI allowlist propagation wiring
Description
Adds first-class support for the Z.AI provider so users can use the
glm-4.6model (200K context, 128K output, text-only, intelligence_score 12) directly through PAL.The provider is built on the project's modern
RegistryBackedProviderMixinpattern with a JSON-driven model registry, so new GLM models can be registered without code changes.ZAI_API_KEYis wired through every surface that already supports the other API keys (server bootstrap, listmodels, version, base tool, model restrictions, Docker compose, deploy/healthcheck scripts, integration test runners).Refs:
Changes Made
ZAIModelProviderhitting the standard/api/paas/v4endpoint (providers/zai.py,providers/registries/zai.py)glm-4.6inconf/zai_models.jsonwithfield_descriptionsandverification_sourcesproviders/__init__.py,providers/registry.py,providers/shared/provider_type.py,server.py,tools/listmodels.py,tools/version.py,tools/shared/base_tool.py,utils/model_restrictions.py,pyproject.tomlZAI_API_KEYthroughdocker-compose.yml,docker/scripts/deploy.{sh,ps1},docker/scripts/healthcheck.py,run_integration_tests.{sh,ps1}tests/test_zai_provider.pywith full provider unit coverage matching the XAI suite (init, capabilities, alias resolution, friendly name,MODEL_CAPABILITIES, restrictions,generate_content) plus integration smoke teststests/conftest.py,tests/test_custom_provider.py,tests/test_listmodels.py,tests/test_server.py,tests/test_docker_*.py).env.example,README.md,docs/getting-started.md,docs/advanced-usage.md,docs/custom_models.md,docs/configuration.md,docker/README.md,docs/docker-deployment.mdTesting
Run all linting and tests (required):
Related Issues
N/A — net-new provider integration.
Checklist
Additional Notes