Add GLM-5.2 (Z.ai) premium cloud backend for routing#2
Open
Tennisee-data wants to merge 1 commit into
Open
Conversation
Add a "zai"/"glm" backend that reuses the OpenAI backend against Z.ai's OpenAI-compatible endpoint, reading ZAI_API_KEY. Routing now resolves a backend per tier (RoutingConfig.premium_backend), so the premium tier and premium_domains can run on GLM-5.2 in the cloud while cheap/medium stay local. Not added to auto-detect — it's an opt-in premium tier, not a default.
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.
What
Lets the premium routing tier run on a frontier cloud model (GLM-5.2 via Z.ai) while cheap/medium tasks stay local. Adds a
zai/glmbackend and per-tier backend selection in the router.Why
GLM-5.2 is an open-weights model in the Claude Opus / GPT-5.5 class, but at 744B params it can't run on ACF's target consumer hardware (8–24GB). It can serve as an on-demand premium tier over its OpenAI-compatible API — local-first by default, frontier on the domains that warrant it (
payments,security,auth,database).Changes
llm_backend/__init__.py—ZaiBackend: the OpenAI backend pre-pointed at Z.ai (https://api.z.ai/api/paas/v4/), readingZAI_API_KEY(orGLM_API_KEY). Registered as"zai"/"glm". Not in auto-detect — opt-in premium tier, not a default.pipeline/config.py—RoutingConfig.premium_backend/premium_base_url. Empty = unchanged (all tiers on the global backend).orchestrator/runner.py—_init_model_routingresolves a backend per tier; cache key is now(backend, model).config.toml— documented opt-in block.tests/test_premium_routing.py— 7 tests.Enabling
export ZAI_API_KEY=sk-...Testing
26 tests pass (was 19). Ruff clean on new code.
🤖 Generated with Claude Code